|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Interface to network client and servers. This is the interface that the networking layer (client and server) must support. Rather than talk to the implementation and network-transport specific networking layer, it is advisable for all communication with the network be handled through this interface. This provides a basic interface for what network objects must support; starting/stopping, sending messages, and handling incoming messages.
Method Summary | |
java.lang.String |
getClientName()
|
java.io.BufferedReader |
getReader()
Returns the reader associated with the networking layer. |
void |
handleMessage(java.lang.String message)
Handle an incoming network message. |
void |
sendMessage(java.lang.String message)
Send an outgoing network message. |
void |
setClientName(java.lang.String name)
|
void |
setGame(GameServer g)
|
void |
startRunning()
Begin operating of the client. |
void |
stopRunning()
Ends operation of the client. |
Method Detail |
public void startRunning()
public void stopRunning()
public void handleMessage(java.lang.String message)
message
- the message that was received from the networkHandler
public void sendMessage(java.lang.String message)
Although this interface is called the Client, both clients and servers can send messages. The semantics of this vary. Calling this method from a client sends a message to the server. On the server, this method is used to send a message back to a specific client.
message
- the message that should be sent to the networkpublic java.io.BufferedReader getReader()
handleMessage(java.lang.String)
is called.
Do not close this stream. It is shared by all of the networking clients and will be disposed within the networking support code.
This reader may block if no input is available. Great care should be used when using this method. Use single-line commands whenever possible.
public java.lang.String getClientName()
public void setClientName(java.lang.String name)
public void setGame(GameServer g)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |