com.googlecode.mobilityrpc.network
Interface Connection

All Known Subinterfaces:
ConnectionInternal
All Known Implementing Classes:
TCPConnection

public interface Connection

The public interface of a connection to a remote machine.

A connection is bidirectional and duplex, having an incoming stream of messages and outgoing stream of messages both of which operate independently. A message can be sent in either direction at any time.

The incoming stream provides messages sent to the local machine by the remote machine. The implementation of the connection will typically be initialized with an object or queue to which it will pass incoming messages.

The connection has an outgoing message queue. The connection will wait for messages to be added to the queue, and when the queue is non-empty it will read from the head of the queue and send messages via the outgoing stream.

Note that when implemented on top of the TCP protocol, that protocol is byte-stream-oriented. As such the connection implementation will have a means to delimit messages sent sequentially over the streams, typically by sending a message length header followed by the actual message.

Author:
Niall Gallagher

Method Summary
 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()
           
 

Method Detail

getConnectionId

ConnectionId getConnectionId()
Returns:
An object which identifies the endpoint (socket and port) of the connection.

enqueueOutgoingMessage

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.

Parameters:
message - A java object representation of a protocol message


Copyright © 2012. All Rights Reserved.