Class ThincMsgHandler

java.lang.Object
  extended by ThincHandler
      extended by ThincMsgHandler

public final class ThincMsgHandler
extends ThincHandler

handles the general frame buffer / video / cursor / init messages from/to the server. it recoginizes the message's type, flag and length then pass them into the proper message object. Moreover, it also takes the control from client messages to send a message. in case of init_reply messages, it pass them into ThincMsgInitReplyHandler object to process it.

Author:
Young Jin Yoon
See Also:
ThincHandler

Field Summary
private  byte flag
           
protected  java.nio.ByteBuffer hd
           
private  ThincMsgInitReplyHandler initHandler
           
private  short length
           
static int MAX_MESSAGE_TYPE
           
private  ThincSMsg[] serverMessage
           
private  byte type
           
 
Fields inherited from class ThincHandler
canvas, client, clientAppData, clientPacData, isSSL, lastSent, MAX_DIRECT_ALLOCATE, rcvResult, recv, sc, send, serverAppData, serverPacData, sslEngine, sslSocket, THINC_HEADERSIZE
 
Constructor Summary
ThincMsgHandler(ThincClient tc, ThincClientCanvas c)
          create ThincMsgHandler object
 
Method Summary
 int getFlag()
           
 ThincMsgInitReplyHandler getInitHandler()
           
 int getLength()
           
protected  java.nio.channels.SocketChannel getSocketChannel()
           
 void init()
          init() receives version information from the server. try to compare the version then send client version information to the server it uses recvBytes() and sendBytes() methods because version information exchange should not have any general thinc header.
private  void initServerMessage()
          initServerMessage() registers server message into array named serverMessage. when reply from server comes, the handler automatically choose the proper message and pass the control to it. if you want to add another server message, you can register the message by adding the line of here.
 int send(ThincCMsg c)
          send() overriden to save last sent messages.
 void setSSL()
          setSSL() sets ThincMsgInitReplyHandler object as SSL secured handler.
 void start()
          start() actually starts to receive message from server. if it comes, this parses general thinc header and pass the control to the proper server message class.
 
Methods inherited from class ThincHandler
closeSocketChannel, createSocketChannel, getLastSent, getMessage, recvBytes, sendBytes, setSSLSocketChannel, SSLHandshake
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_MESSAGE_TYPE

public static final int MAX_MESSAGE_TYPE
See Also:
Constant Field Values

hd

protected java.nio.ByteBuffer hd

initHandler

private ThincMsgInitReplyHandler initHandler

serverMessage

private ThincSMsg[] serverMessage

type

private byte type

flag

private byte flag

length

private short length
Constructor Detail

ThincMsgHandler

public ThincMsgHandler(ThincClient tc,
                       ThincClientCanvas c)
                throws ThincException
create ThincMsgHandler object

Parameters:
tc - ThincClient object which invokes this
c - ThincClientCanvas object to draw
Throws:
ThincException
Method Detail

initServerMessage

private void initServerMessage()
initServerMessage() registers server message into array named serverMessage. when reply from server comes, the handler automatically choose the proper message and pass the control to it. if you want to add another server message, you can register the message by adding the line of here.


init

public void init()
          throws ThincException
init() receives version information from the server. try to compare the version then send client version information to the server it uses recvBytes() and sendBytes() methods because version information exchange should not have any general thinc header.

Throws:
ThincException

start

public void start()
           throws ThincException
start() actually starts to receive message from server. if it comes, this parses general thinc header and pass the control to the proper server message class.

Throws:
ThincException

send

public int send(ThincCMsg c)
         throws ThincException
send() overriden to save last sent messages.

Overrides:
send in class ThincHandler
Parameters:
c - ThincCMsg classes to send
Returns:
number of bytes sent
Throws:
ThincException
See Also:
ThincHandler

setSSL

public void setSSL()
setSSL() sets ThincMsgInitReplyHandler object as SSL secured handler.


getInitHandler

public ThincMsgInitReplyHandler getInitHandler()

getSocketChannel

protected java.nio.channels.SocketChannel getSocketChannel()

getFlag

public int getFlag()

getLength

public int getLength()