|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectThincHandler
public abstract class ThincHandler
abstract class for handling network messages. it provides various methods to implement any network handler derived from this.
Field Summary | |
---|---|
protected ThincClientCanvas |
canvas
|
protected ThincClient |
client
|
protected java.nio.ByteBuffer |
clientAppData
|
protected java.nio.ByteBuffer |
clientPacData
|
protected boolean |
isSSL
|
protected byte |
lastSent
|
protected static int |
MAX_DIRECT_ALLOCATE
|
protected javax.net.ssl.SSLEngineResult |
rcvResult
|
protected java.nio.ByteBuffer |
recv
|
protected java.nio.channels.SocketChannel |
sc
|
protected java.nio.ByteBuffer |
send
|
protected java.nio.ByteBuffer |
serverAppData
|
protected java.nio.ByteBuffer |
serverPacData
|
protected javax.net.ssl.SSLEngine |
sslEngine
|
protected javax.net.ssl.SSLSocket |
sslSocket
|
protected static int |
THINC_HEADERSIZE
|
Constructor Summary | |
---|---|
ThincHandler(ThincClient tc,
ThincClientCanvas ca)
|
Method Summary | |
---|---|
protected void |
closeSocketChannel()
closeSocketChannel() closes the connection from the server |
protected java.nio.channels.SocketChannel |
createSocketChannel(java.lang.String host,
int port)
createSocketChannel() creates network connection to server |
byte |
getLastSent()
getLastSent() get the thinc type of last sent messages |
java.nio.ByteBuffer |
getMessage(int size)
getMessage() get messages from the server. |
private void |
putThincHeader(java.nio.ByteBuffer b,
byte type,
byte flag,
short length)
putThincHeader() puts the general thinc header into ByteBuffer |
protected int |
recvBytes(java.nio.ByteBuffer bb)
recvBytes() is the primitive method used by getMessage method. it also used when version exchange required (which does not have general thinc header |
int |
send(ThincCMsg c)
send() send messages to the server. |
protected int |
sendBytes(java.nio.ByteBuffer bb)
sendBytes() is the primitive method used by send method. it also used when version exchange required (which does not have general thinc header |
void |
setSSLSocketChannel(java.lang.String host,
int port)
setSSLSocketChannel() uses SSLEngine class in Java to establish SSL connection. |
void |
SSLHandshake()
SSLHandshake() do handshake for SSLEngine . |
private int |
unwrapSSL(java.nio.ByteBuffer bb)
unwrapSSL() unwrap from ssl messages & send it |
private int |
wrapSSL(java.nio.ByteBuffer bb)
wrapSSL() wrap into ssl messages & send it |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static final int THINC_HEADERSIZE
protected static final int MAX_DIRECT_ALLOCATE
protected java.nio.channels.SocketChannel sc
protected java.nio.ByteBuffer recv
protected java.nio.ByteBuffer send
protected ThincClient client
protected ThincClientCanvas canvas
protected byte lastSent
protected boolean isSSL
protected javax.net.ssl.SSLEngine sslEngine
protected javax.net.ssl.SSLSocket sslSocket
protected java.nio.ByteBuffer clientAppData
protected java.nio.ByteBuffer clientPacData
protected java.nio.ByteBuffer serverAppData
protected java.nio.ByteBuffer serverPacData
protected javax.net.ssl.SSLEngineResult rcvResult
Constructor Detail |
---|
public ThincHandler(ThincClient tc, ThincClientCanvas ca)
Method Detail |
---|
protected java.nio.channels.SocketChannel createSocketChannel(java.lang.String host, int port) throws ThincException
host
- domain name for serverport
- port number for server
SocketChannel
object to be created
ThincException
protected void closeSocketChannel() throws ThincException
ThincException
public int send(ThincCMsg c) throws ThincException
c
- ThincCMsg
object to send
ThincException
private void putThincHeader(java.nio.ByteBuffer b, byte type, byte flag, short length)
ByteBuffer
b
- target ByteBuffer
to puttype
- type of the messagesflag
- flag of the messageslength
- length of the messagesprotected int sendBytes(java.nio.ByteBuffer bb) throws ThincException
bb
- ByteBuffer
to send
ThincException
private int wrapSSL(java.nio.ByteBuffer bb) throws ThincException
bb
- original ByteBuffer
to be encoded
ThincException
public java.nio.ByteBuffer getMessage(int size) throws ThincException
size
- ByteBuffer
size to be received
ByteBuffer
received
ThincException
protected int recvBytes(java.nio.ByteBuffer bb) throws ThincException
bb
- ByteBuffer
to receive
ThincException
private int unwrapSSL(java.nio.ByteBuffer bb) throws ThincException
bb
- original ByteBuffer
to receive
ThincException
public byte getLastSent()
public void setSSLSocketChannel(java.lang.String host, int port) throws ThincException
SSLEngine
class in Java to establish SSL connection.
SSLEngine
supports only non-blocking mode.
We need to find another way to use SSLEngine
because
it is currently implemented with polling
ThincException
public void SSLHandshake() throws ThincException
SSLEngine
.
ThincException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |