server.framework.network
Interface Communicator

All Known Implementing Classes:
PingTest, ServerSocketCommunicator, TestModule, TransferSpeedTest

public interface Communicator

Author:
Martin Jarrett, Eivind Sorteberg

Method Summary
 void close()
          Used to close the communicator object, and free resources.
 boolean connect(java.lang.String[] addresses)
          Connects to the server(s) with the specified address(es).
 void disconnect(java.lang.String[] addresses)
          Disconnects from the specified address(es).
 void notifyAboutMessageReceived(java.lang.Object message)
          Called when a message is received.
 void searchForNodes()
          Searches for network nodes to connect to.
 void sendMessage(java.lang.Object message, boolean confirm)
          Called when the server's models want to send a message using its Communicator instances.
 

Method Detail

connect

boolean connect(java.lang.String[] addresses)
Connects to the server(s) with the specified address(es). The format of these addresses depends on the type of communication specified in the interface implementation. Since this interface is implemented on the client, this message is not likely to be used.

Parameters:
addresses - The address(es) to connect to.
Returns:
Whether the connection was successful or not.

disconnect

void disconnect(java.lang.String[] addresses)
Disconnects from the specified address(es).

Parameters:
addresses - The address(es) to disconnect from.

sendMessage

void sendMessage(java.lang.Object message,
                 boolean confirm)
Called when the server's models want to send a message using its Communicator instances. This message should be created by the MessageParser implementation, to ensure that the format of the message follow the specified format. In implementations of this method, the confirm flag can be used to implement guaranteed delivery of critical messages, similar to that found in the TCP transport protocol.

Parameters:
message - The message to send.
confirm - Whether receival of the message should be confirmed by the receiver.

notifyAboutMessageReceived

void notifyAboutMessageReceived(java.lang.Object message)
Called when a message is received. The implementation of this method should notify the server's models that a message has been received.

Parameters:
message - The message that has been received.

close

void close()
Used to close the communicator object, and free resources.


searchForNodes

void searchForNodes()
Searches for network nodes to connect to. Is not used for client-server networks, but can be useful if the framework is used in a peer-to-peer network.