com.googlecode.mobilityrpc.network.impl.tcp
Class TCPConnection

java.lang.Object
  extended by com.googlecode.mobilityrpc.network.impl.tcp.TCPConnection
All Implemented Interfaces:
Destroyable, Initializable, Managed, Connection, ConnectionInternal

public class TCPConnection
extends Object
implements ConnectionInternal

Author:
Niall Gallagher

Constructor Summary
TCPConnection(Socket socket, ConnectionId connectionId, IncomingMessageHandler incomingMessageHandler, ConnectionStateListener connectionStateListener)
           
 
Method Summary
 void destroy()
          Destroys (closes/shuts down) the resource(s) managed by the object, closing connections, stopping threads etc.
 void enqueueOutgoingMessage(byte[] message)
          Submits the specified message to the connection's outgoing message queue, such that it will be sent to the machine at the other end of the connection for processing.
 ConnectionId getConnectionId()
           
 void init()
          Initializes the resource(s) managed by the object, opening connections, starting threads etc.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TCPConnection

public TCPConnection(Socket socket,
                     ConnectionId connectionId,
                     IncomingMessageHandler incomingMessageHandler,
                     ConnectionStateListener connectionStateListener)
Parameters:
socket - The socket through which this connection communicates.
connectionId - The connection id, comprising the address, port and auxiliary connection id. If auxiliary connection id is zero, indicates that this is a primary connection, otherwise this is simply a number which distinguishes this connection from other "auxiliary" connections to the remote machine
incomingMessageHandler - An object to which messages received on this connection should be supplied.
connectionStateListener - An object which this connection should notify if the connection is closed.
Method Detail

getConnectionId

public ConnectionId getConnectionId()
Specified by:
getConnectionId in interface Connection
Returns:
An object which identifies the endpoint (socket and port) of the connection.

enqueueOutgoingMessage

public void enqueueOutgoingMessage(byte[] message)
Description copied from interface: Connection
Submits the specified message to the connection's outgoing message queue, such that it will be sent to the machine at the other end of the connection for processing.

Specified by:
enqueueOutgoingMessage in interface Connection
Parameters:
message - A java object representation of a protocol message

init

public void init()
Description copied from interface: Initializable
Initializes the resource(s) managed by the object, opening connections, starting threads etc. as necessary.

Specified by:
init in interface Initializable

destroy

public void destroy()
Description copied from interface: Destroyable
Destroys (closes/shuts down) the resource(s) managed by the object, closing connections, stopping threads etc. as necessary.

Specified by:
destroy in interface Destroyable


Copyright © 2012. All Rights Reserved.