|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfulmine.AbstractLifeCycle
fulmine.distribution.connection.tcp.TcpConnectionParameters
fulmine.distribution.connection.tcp.AbstractSocketChannelConnection
fulmine.distribution.connection.tcp.TcpConnection
public final class TcpConnection
Handles the socket processing for a single connection to a remote
IFrameworkContext.
Received TCP messages from the remote context may be concatenated together; e.g. the remote context sends "conn:lasers" then "syn". These may be received by this connection as a single message "conn:laserssyn". To be able to distinguish these messages, each message is prefixed with the byte length of the application message. This prefix is always 4 bytes, big-endian; e.g. the above example would resolve to "11conn:lasers3syn".
This generates the following events:
When this object is destroyed via the AbstractLifeCycle.destroy() method, this only
closes down the TCP IO resources and signals that only when all pending
MessageEvents have been processed should this object's
IEventSource functions be terminated; this will then remove any
IEventListeners that would normally receive messages from this
connection.
| Field Summary |
|---|
| Fields inherited from class fulmine.distribution.connection.tcp.AbstractSocketChannelConnection |
|---|
destroyWhenMessagesProcessed, eventSourceDelegate, messagesToProcess |
| Constructor Summary | |
|---|---|
TcpConnection(IFrameworkContext context,
TcpConnectionBroker broker,
String remoteContextIdentity,
String address,
int port,
int connectionHashCode)
Standard constructor |
|
| Method Summary | |
|---|---|
protected void |
doComponentDestroy()
|
protected void |
doDestroy()
Destroy the internal TCP I/O components. |
protected AsyncLog |
getLog()
Get the log to use for the object hierarchy |
SelectionKey |
getSelectionKey()
|
void |
run()
Run the task associated with the operation and selection key |
void |
send(byte[] data)
Add the data to the pending messages list |
void |
setSelectionKey(SelectionKey selectionKey)
Receives the selection key returned from the SelectableChannel.register(java.nio.channels.Selector, int)
method called during the
SelectorTasks.register(int, SelectableChannel, ISelectionKeyTask)
method. |
| Methods inherited from class fulmine.distribution.connection.tcp.AbstractSocketChannelConnection |
|---|
addEvent, addListener, connectionHandshakeComplete, doStart, getContext, getEventSourceGroupId, getListeners, getSocketChannel, isConnected, isConnectionHandshakeComplete, isOutbound, removeListener, removeListeners, toDetailedString, toIdentityString, toString |
| Methods inherited from class fulmine.distribution.connection.tcp.TcpConnectionParameters |
|---|
equals, getAddress, getDomain, getIdentity, getRemoteContextHashCode, getRemoteContextIdentity, getRemoteHostAddress, getRemoteHostTcpPort, getType, hashCode, isEqual, setIdentity, setRemoteContextHashCode |
| Methods inherited from class fulmine.AbstractLifeCycle |
|---|
checkActive, destroy, finalize, isActive, start |
| Methods inherited from class java.lang.Object |
|---|
clone, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface fulmine.distribution.connection.IConnection |
|---|
isOutbound |
| Methods inherited from interface fulmine.distribution.connection.IConnectionParameters |
|---|
getRemoteContextHashCode, getRemoteContextIdentity, isEqual |
| Constructor Detail |
|---|
public TcpConnection(IFrameworkContext context,
TcpConnectionBroker broker,
String remoteContextIdentity,
String address,
int port,
int connectionHashCode)
broker - the TcpConnectionBrokerremoteContextIdentity - the identity of the remote context this connection connects toaddress - the TCP address of the server port the context exposes to
other remote contextsport - the TCP server port the context exposes to other remote
contextsconnectionHashCode - the hashcode of the connection to the remote context| Method Detail |
|---|
public void send(byte[] data)
send in interface IConnectiondata - the data to add to the pending messagespublic void run()
ISelectionKeyTask
run in interface ISelectionKeyTaskprotected void doDestroy()
AbstractSocketChannelConnection
doDestroy in class AbstractSocketChannelConnectionpublic SelectionKey getSelectionKey()
public void setSelectionKey(SelectionKey selectionKey)
ISelectionKeyTaskSelectableChannel.register(java.nio.channels.Selector, int)
method called during the
SelectorTasks.register(int, SelectableChannel, ISelectionKeyTask)
method.
setSelectionKey in interface ISelectionKeyTaskselectionKey - the selection key for thisprotected AsyncLog getLog()
AbstractLifeCycle
getLog in class AbstractLifeCycleprotected void doComponentDestroy()
doComponentDestroy in class AbstractSocketChannelConnection
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||