roomba.roombanetwork.server
Class RoombaNetworkServer

java.lang.Object
  extended by roomba.roombanetwork.server.RoombaNetworkServer
All Implemented Interfaces:
SocketListener

public class RoombaNetworkServer
extends java.lang.Object
implements SocketListener

This class performs the role of RNS (Roomba Network Server). It handles connections from RNCs and routes messages appropriately.

Author:
Drew Housten

Field Summary
static java.lang.String PROTOCOL_VERSION
          The Protocol version that the server is using
 
Constructor Summary
RoombaNetworkServer(int port)
          Constructor for creating the RNS.
 
Method Summary
 void disconnectClient(int id)
          Called when a connection to a client should be disconnected.
 void establishClient(int id, java.lang.String host, int port)
          Called when a connection to a client should be established.
 RNCTable getRNCTable()
          Accessor to the RNC Table
static void main(java.lang.String[] args)
          The main method to start the RNS.
 void messageReceived(java.lang.String message)
          Called when an incoming message is received.
 void sendMessage(int receiverId, java.lang.String message)
          Called when an outgoing message should be sent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROTOCOL_VERSION

public static final java.lang.String PROTOCOL_VERSION
The Protocol version that the server is using

See Also:
Constant Field Values
Constructor Detail

RoombaNetworkServer

public RoombaNetworkServer(int port)
Constructor for creating the RNS.

Parameters:
port - The port number that the server should operate on
Method Detail

messageReceived

public void messageReceived(java.lang.String message)
Called when an incoming message is received. This will parse the message and get it to the right handler

Specified by:
messageReceived in interface SocketListener
Parameters:
message - The message that has been received

establishClient

public void establishClient(int id,
                            java.lang.String host,
                            int port)
Called when a connection to a client should be established.

Parameters:
id - The client's ID
host - The client's host
port - The client's port

disconnectClient

public void disconnectClient(int id)
Called when a connection to a client should be disconnected.

Parameters:
id - The client's ID

getRNCTable

public RNCTable getRNCTable()
Accessor to the RNC Table

Returns:
the current RNC table

sendMessage

public void sendMessage(int receiverId,
                        java.lang.String message)
Called when an outgoing message should be sent

Parameters:
receiverId - The receiver client's ID
message - The message to send

main

public static void main(java.lang.String[] args)
The main method to start the RNS.

Parameters:
args - The args should include 1 argument (optional), which is the port that the RNS should listen on. If the port is not provided, the default port of 7777 will be used.