ocsf.server
Class AdaptableServer

java.lang.Object
  |
  +--ocsf.server.AbstractServer
        |
        +--ocsf.server.AdaptableServer

class AdaptableServer
extends AbstractServer

The AdaptableServer is an adapter class that extends the AbstractServer class in place of the AbstractObservableServer .

Project Name: OCSF (Object Client-Server Framework)


Field Summary
private  ObservableServer server
          The adapter used to simulate multiple class inheritance.
 
Fields inherited from class ocsf.server.AbstractServer
backlog, clientThreadGroup, connectionListener, port, readyToStop, serverSocket, timeout
 
Constructor Summary
AdaptableServer(int port, ObservableServer server)
          Constructs the server adapter.
 
Method Summary
protected  void clientConnected(ConnectionToClient client)
          Hook method called each time a new client connection is accepted.
protected  void clientDisconnected(ConnectionToClient client)
          Hook method called each time a client disconnects.
protected  void clientException(ConnectionToClient client, java.lang.Throwable exception)
          Hook method called each time an exception is raised in a client thread.
protected  void handleMessageFromClient(java.lang.Object msg, ConnectionToClient client)
          Handles a command sent from the client to the server.
protected  void listeningException(java.lang.Throwable exception)
          Hook method called when the server stops accepting connections because an exception has been raised.
protected  void serverClosed()
          Hook method called when the server is closed.
protected  void serverStarted()
          Hook method called when the server starts listening for connections.
protected  void serverStopped()
          Hook method called when the server stops accepting connections.
 
Methods inherited from class ocsf.server.AbstractServer
close, getClientConnections, getNumberOfClients, getPort, isListening, listen, receiveMessageFromClient, run, sendToAllClients, setBacklog, setPort, setTimeout, stopListening
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

server

private ObservableServer server
The adapter used to simulate multiple class inheritance.
Constructor Detail

AdaptableServer

public AdaptableServer(int port,
                       ObservableServer server)
Constructs the server adapter.
Parameters:
host - the server's host name.
port - the port number.
Method Detail

clientConnected

protected final void clientConnected(ConnectionToClient client)
Hook method called each time a new client connection is accepted.
Parameters:
client - the connection connected to the client.
Overrides:
clientConnected in class AbstractServer

clientDisconnected

protected final void clientDisconnected(ConnectionToClient client)
Hook method called each time a client disconnects.
Parameters:
client - the connection with the client.
Overrides:
clientDisconnected in class AbstractServer

clientException

protected final void clientException(ConnectionToClient client,
                                     java.lang.Throwable exception)
Hook method called each time an exception is raised in a client thread.
Parameters:
client - the client that raised the exception.
exception - the exception raised.
Overrides:
clientException in class AbstractServer

listeningException

protected final void listeningException(java.lang.Throwable exception)
Hook method called when the server stops accepting connections because an exception has been raised.
Parameters:
exception - the exception raised.
Overrides:
listeningException in class AbstractServer

serverStopped

protected final void serverStopped()
Hook method called when the server stops accepting connections.
Overrides:
serverStopped in class AbstractServer

serverStarted

protected final void serverStarted()
Hook method called when the server starts listening for connections.
Overrides:
serverStarted in class AbstractServer

serverClosed

protected final void serverClosed()
Hook method called when the server is closed.
Overrides:
serverClosed in class AbstractServer

handleMessageFromClient

protected final void handleMessageFromClient(java.lang.Object msg,
                                             ConnectionToClient client)
Handles a command sent from the client to the server.
Parameters:
msg - the message sent.
client - the connection connected to the client that sent the message.
Overrides:
handleMessageFromClient in class AbstractServer