public class Server<P extends Server.Protocol,O extends Server.ServerObserver> extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
Server.Protocol<S extends Server>
Implement this to define the behavior of the communication on the server side.
|
static interface |
Server.ServerObserver |
| Modifier and Type | Field and Description |
|---|---|
protected ObserverLord<O> |
observerLord |
protected P |
protocol |
| Modifier and Type | Method and Description |
|---|---|
void |
addServerObserver(O observer,
boolean inEventQueue) |
protected void |
communicationsStarted()
this exists solely so it can be overridden.
|
int |
getPort() |
boolean |
isServerRunning() |
void |
removeServerObserver(O observer) |
void |
requestShutdown() |
void |
sendMessage(String messageType,
String message)
Call this to send a message.
|
void |
sendMessage(String messageType,
String message,
Serializable data)
Call this to send a message with some binary data.
|
boolean |
start()
Call this to start the server.
|
void |
stop() |
protected P extends Server.Protocol protocol
protected ObserverLord<O extends Server.ServerObserver> observerLord
public Server(P protocol)
public int getPort()
public boolean start()
protected void communicationsStarted()
public void requestShutdown()
public boolean isServerRunning()
public void sendMessage(String messageType, String message)
messageType - the message type. Whatever the client and server want.message - the message being sent.public void sendMessage(String messageType, String message, Serializable data)
messageType - the message type. Whatever the client and server want.message - the message being sentdata - the data being sent. Must be serializable.public void stop()
public void addServerObserver(O observer, boolean inEventQueue)
public void removeServerObserver(O observer)
Copyright © 2013. All rights reserved