fate.network
Class ClientConnection
java.lang.Object
|
+--fate.network.ClientConnection
- public class ClientConnection
- extends java.lang.Object
Attempts to create a network connection between client and server.
After calling connect(LoginMessage), on sucessful connection with
the server, this will spawn a new ClientThread to handle incoming messages.
Messages will be stored in the messageBuffer and can be retrieved
sequentially using messagesAvailable() and nextMessage().
|
Constructor Summary |
ClientConnection(java.lang.String host,
int port)
Creates new ClientConnection |
|
Method Summary |
boolean |
connect(LoginMessage loginMessage)
Opens a connection to the server |
boolean |
messagesAvailable()
Returns true if there are messages in the message buffer |
java.lang.Object |
nextMessage()
Returns the next message in the buffer, or NULL is there are none. |
void |
receiveMessage(java.lang.Object msg)
Called by the communications thread to receive a message |
void |
sendMessage(GameMessage msg)
Sends a message to the server |
| Methods inherited from class java.lang.Object |
clone,
equals,
finalize,
getClass,
hashCode,
notify,
notifyAll,
toString,
wait,
wait,
wait |
ClientConnection
public ClientConnection(java.lang.String host,
int port)
- Creates new ClientConnection
connect
public boolean connect(LoginMessage loginMessage)
throws java.net.UnknownHostException,
java.io.IOException
- Opens a connection to the server
sendMessage
public void sendMessage(GameMessage msg)
- Sends a message to the server
receiveMessage
public void receiveMessage(java.lang.Object msg)
throws java.io.IOException
- Called by the communications thread to receive a message
messagesAvailable
public boolean messagesAvailable()
- Returns true if there are messages in the message buffer
nextMessage
public java.lang.Object nextMessage()
- Returns the next message in the buffer, or NULL is there are none.
Should check with messagesAvailable first to see if there are any