|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmhframework.net.client.MHClientModule
public class MHClientModule
This class can be instantiated by any client application that needs to communicate with a multiplayer server. It simply needs the IP address, and optionally the port number, of the server.
Field Summary | |
---|---|
static int |
STATUS_CONNECTED
|
static int |
STATUS_DISCONNECTED
|
Constructor Summary | |
---|---|
MHClientModule(java.lang.String hostIP)
Connects to the server specified by hostIP using the default port (5000), and then begins a background thread to receive messages. |
|
MHClientModule(java.lang.String hostIP,
int port)
Connects to the server specified by hostIP on the port specified by port, and then begins a background thread to receive messages. |
Method Summary | |
---|---|
void |
disconnect()
|
int |
getClientID()
|
MHSerializableClientList |
getClientList()
Returns a list of clients who are connected to the same server as this client module. |
int |
getMaxConnections()
|
MHNetworkMessage |
getMessage()
Retrieve the next message from the queue. |
java.lang.String |
getPlayerName()
|
int |
getStatus()
|
java.lang.String |
getStatusMessage()
|
boolean |
isMessageWaiting()
Return true if the queue of incoming messages is not empty; return false it if is. |
MHNetworkMessage |
peek()
Peek at the next message in the queue without removing it. |
void |
registerPlayerColor(java.awt.Color color)
|
void |
registerPlayerName(java.lang.String name)
|
void |
run()
Continuously receives server messages and adds them to this class' internal message queue. |
void |
sendChat(java.lang.String message)
|
void |
sendMessage(MHNetworkMessage message)
Sends a message to the server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int STATUS_CONNECTED
public static final int STATUS_DISCONNECTED
Constructor Detail |
---|
public MHClientModule(java.lang.String hostIP)
hostIP
- A string containing the IP address of the serverpublic MHClientModule(java.lang.String hostIP, int port)
hostIP
- A string containing the IP address of the server.port
- An integer indicating the server's listening
port.Method Detail |
---|
public int getClientID()
public MHNetworkMessage getMessage()
public MHNetworkMessage peek()
public boolean isMessageWaiting()
public void run()
run
in interface java.lang.Runnable
public int getStatus()
public java.lang.String getStatusMessage()
public MHSerializableClientList getClientList()
public void sendMessage(MHNetworkMessage message)
public void disconnect()
public int getMaxConnections()
public void sendChat(java.lang.String message)
public void registerPlayerName(java.lang.String name)
public void registerPlayerColor(java.awt.Color color)
public java.lang.String getPlayerName()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |