public class NetworkedWorldModelClient extends java.lang.Object implements NetworkedWorldClient
Constructor and Description |
---|
NetworkedWorldModelClient(NetworkMessageDecoder decoder)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(L listener)
Add a client connection listener.
|
void |
addMessage(NetworkMessage message)
Add a network message.
|
void |
addMessages(java.util.Collection<NetworkMessage> messages)
Add a list of network messages.
|
void |
addNetworkable(Networkable networkable)
Add a networkable entity to the world.
|
void |
connect(java.lang.String ip,
int port)
Connect to a server.
|
void |
disconnect()
Disconnect.
|
int |
getBandwidth()
Get the amount of bytes sent per second.
|
byte |
getId()
Get the network id.
|
java.lang.String |
getName()
Get the client name.
|
int |
getPing()
Get the ping from the server (time elapsed between the ping request and response).
|
void |
notifyClientConnected(java.lang.Byte id,
java.lang.String name)
Notify when a new client is connected.
|
void |
notifyClientConnected(java.lang.Byte id,
java.lang.String name)
Notify when a new client is connected.
|
void |
notifyClientDisconnected(java.lang.Byte id,
java.lang.String name)
Notify when a client is disconnected.
|
void |
notifyClientDisconnected(java.lang.Byte id,
java.lang.String name)
Notify when a client is disconnected.
|
void |
notifyClientNameChanged(java.lang.Byte id,
java.lang.String name)
Notify when a client changed its name.
|
void |
notifyClientNameChanged(java.lang.Byte id,
java.lang.String name)
Notify when a client changed its name.
|
void |
notifyConnectionEstablished(java.lang.Byte id,
java.lang.String name)
Notify when the connection to the server is established.
|
void |
notifyConnectionTerminated(java.lang.Byte id)
Notify when the connection to the server is terminated.
|
void |
notifyMessageOfTheDay(java.lang.String messageOfTheDay)
Notify the message of the day.
|
void |
receiveMessages()
Receive all messages from the network.
|
void |
removeListener(L listener)
Remove a client connection listener.
|
void |
removeNetworkable(Networkable networkable)
Remove a networkable entity to the world.
|
void |
sendMessages()
Send all messages to the network.
|
void |
setName(java.lang.String name)
Set the client new name.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addMessage, addMessages, addNetworkable, getBandwidth, receiveMessages, removeNetworkable, sendMessages
public NetworkedWorldModelClient(NetworkMessageDecoder decoder)
decoder
- The decoder reference.public void connect(java.lang.String ip, int port)
NetworkedWorldClient
connect
in interface NetworkedWorldClient
ip
- The server ip.port
- The server port.public void disconnect()
NetworkedWorld
disconnect
in interface NetworkedWorld
public void setName(java.lang.String name)
NetworkedWorldClient
setName
in interface NetworkedWorldClient
name
- The new name.public java.lang.String getName()
NetworkedWorldClient
getName
in interface NetworkedWorldClient
public int getPing()
NetworkedWorldClient
getPing
in interface NetworkedWorldClient
public byte getId()
NetworkedWorldClient
getId
in interface NetworkedWorldClient
public void notifyConnectionEstablished(java.lang.Byte id, java.lang.String name)
ConnectionListener
notifyConnectionEstablished
in interface ConnectionListener
id
- The id received.name
- The client name.public void notifyMessageOfTheDay(java.lang.String messageOfTheDay)
ConnectionListener
notifyMessageOfTheDay
in interface ConnectionListener
messageOfTheDay
- The message of the day.public void notifyConnectionTerminated(java.lang.Byte id)
ConnectionListener
notifyConnectionTerminated
in interface ConnectionListener
id
- The id received.public void notifyClientConnected(java.lang.Byte id, java.lang.String name)
id
- The client id.name
- The client name.public void notifyClientDisconnected(java.lang.Byte id, java.lang.String name)
id
- The client id.name
- The client name.public void notifyClientNameChanged(java.lang.Byte id, java.lang.String name)
id
- The client id.name
- The client new name.public void addListener(L listener)
listener
- The listener.public void removeListener(L listener)
listener
- The listener.public void addNetworkable(Networkable networkable)
NetworkedWorld
addNetworkable
in interface NetworkedWorld
networkable
- The networkable entity.public void removeNetworkable(Networkable networkable)
NetworkedWorld
removeNetworkable
in interface NetworkedWorld
networkable
- The networkable entity.public void addMessage(NetworkMessage message)
NetworkedWorld
addMessage
in interface NetworkedWorld
message
- The message.public void addMessages(java.util.Collection<NetworkMessage> messages)
NetworkedWorld
addMessages
in interface NetworkedWorld
messages
- The messages list.public void sendMessages()
NetworkedWorld
sendMessages
in interface NetworkedWorld
public void receiveMessages()
NetworkedWorld
receiveMessages
in interface NetworkedWorld
public int getBandwidth()
NetworkedWorld
getBandwidth
in interface NetworkedWorld
public void notifyClientConnected(java.lang.Byte id, java.lang.String name)
id
- The client id.name
- The client name.public void notifyClientDisconnected(java.lang.Byte id, java.lang.String name)
id
- The client id.name
- The client name.public void notifyClientNameChanged(java.lang.Byte id, java.lang.String name)
id
- The client id.name
- The client new name.