Package ucar.unidata.collab
Class Server
java.lang.Object
ucar.unidata.collab.Server
- Direct Known Subclasses:
- CollabServer
A generic server
- Author:
- Metapps development team
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidAdd the given client to the list of clients managed by this server.voidAdd the given client to the list of clients managed by this server.protected ClientcreateClient(Socket clientSocket) A factory method for creating a new client.Gets the clients.booleanGet the IsRunning property.protected voidhandleIncomingMessage(Client fromClient, String message) Handle the message rcvd from the given client.booleanDoes this server have any clients.protected voidinitClient(Socket clientSocket) Create a new client object and listen for input.protected voidlogException(String msg, Exception exc) Log exception.static voidThe main method.protected voidnotifyClientAdd(Client client) Gets called when we have added a new client.protected voidnotifyClientRemove(Client client) Gets called when we have removed a client.protected voidGets called when we are starting to listenprotected voidGets called when we are done running on the server socketvoidremoveClient(Client client) Remove the given client from the list of clients managed by this server.voidStart server.voidstartServer(int newPort) Start server.voidStop server.voidWrite.voidWrite.
- 
Field Details- 
DEFAULT_PORTpublic static int DEFAULT_PORT_more_
 
- 
- 
Constructor Details- 
Serverpublic Server()Create a new Server connection.
- 
Serverpublic Server(int port) Create a new Server connection on the given port.- Parameters:
- port- the port
 
 
- 
- 
Method Details- 
startServerStart server.- Parameters:
- newPort- the new port
- Throws:
- IOException- Signals that an I/O exception has occurred.
 
- 
startServerStart server.- Throws:
- IOException- Signals that an I/O exception has occurred.
 
- 
stopServerpublic void stopServer()Stop server.
- 
notifyServerStartprotected void notifyServerStart()Gets called when we are starting to listen
- 
notifyServerStopprotected void notifyServerStop()Gets called when we are done running on the server socket
- 
notifyClientAddGets called when we have added a new client.- Parameters:
- client- the client
 
- 
notifyClientRemoveGets called when we have removed a client.- Parameters:
- client- the client
 
- 
getIsRunningpublic boolean getIsRunning()Get the IsRunning property.- Returns:
- The IsRunning
 
- 
createClientA factory method for creating a new client.- Parameters:
- clientSocket- The socket we are connected to the client with.
- Returns:
- a new Client
- Throws:
- IOException- Signals that an I/O exception has occurred.
 
- 
initClientCreate a new client object and listen for input.- Parameters:
- clientSocket- the client socket
 
- 
getClientsGets the clients.- Returns:
- the clients
 
- 
hasClientspublic boolean hasClients()Does this server have any clients.- Returns:
- true, if successful
 
- 
addClientAdd the given client to the list of clients managed by this server.- Parameters:
- client- the client
 
- 
addClientAdd the given client to the list of clients managed by this server.- Parameters:
- client- the client
- andStartListening- the and start listening
 
- 
removeClientRemove the given client from the list of clients managed by this server.- Parameters:
- client- the client
 
- 
handleIncomingMessageHandle the message rcvd from the given client. The default is to just turn around and write it to each of the other clients.- Parameters:
- fromClient- the from client
- message- the message
 
- 
writeWrite.- Parameters:
- message- the message
 
- 
writeWrite.- Parameters:
- message- the message
- exceptClient- the except client
 
- 
logExceptionLog exception.- Parameters:
- msg- the msg
- exc- the exc
 
- 
mainThe main method.- Parameters:
- args- the arguments
 
 
-