datum API Documentation

datum.protocol
Interface Receiver

All Known Implementing Classes:
Client, Server

public interface Receiver

Receives events from both server and client Connections. Can be used to have the application respond immediately to incoming data, or connection status changes. One Receiver object can be used to received events from multiple connections, as is the case for Servers. The Connection argument for each event returns a reference to which Connection the event is in relation to.

See Also:
Connection

Method Summary
 void connected(Connection connection)
          Called when a Connection has successfully connected and the definitions table has been already transfered.
 void disconnected(Connection connection)
          Called after a Connection has been dropped.
 void error(Connection connection, String errorMessage)
          Called when an error occurs for a Connection.
 void receivedData(Connection connection, Hashtable data)
          Called every time a complete message is received by a Connection.
 

Method Detail

error

public void error(Connection connection,
                  String errorMessage)
Called when an error occurs for a Connection. A simple response would be to display the error to the user and take no further action. Many fatal errors automatically disconnect the Connection, which is detectable as the disconnected method will be called immediately following the error. Note that the Server class sometimes calls error with connection equal to null. This indicates that an error not related to a particular client conneciton occured.

Parameters:
connection - The connection which this error is coming from.
errorMessage - A description of the error that occured.
See Also:
disconnected(Connection)

connected

public void connected(Connection connection)
Called when a Connection has successfully connected and the definitions table has been already transfered. Thus send commands can be sent immediately following the call to this method, or even in this method.

Parameters:
connection - The connection which has just been established.
See Also:
Connection.send(java.lang.Object[])

receivedData

public void receivedData(Connection connection,
                         Hashtable data)
Called every time a complete message is received by a Connection. The data argument contains the message mapped by field name according to definitions stored in the Library for this Connection. Clients will often get most data from the server using the Library class, though, and only react to certain types of messages in the receivedData method which require immediate attention.

Parameters:
connection - The connection which received a message.
data - The Hashtable which contains field name-value pairs from the message.
See Also:
Connection.getLibrary()

disconnected

public void disconnected(Connection connection)
Called after a Connection has been dropped. Once this method is called the Connection is already gone, so no messages can be sent after this event.

Parameters:
connection - The connection which has just been dropped.

Up to datum