Public Member Functions | |
boolean | isActive () |
boolean | isGameServer () |
void | destroy () |
void | reset () |
void | startServer (boolean isGameServer) throws NetworkException, IllegalStateException |
void | connect (InetAddress serverIpAddress) throws NetworkException, IllegalStateException |
void | send (NetworkCommand command) |
void | update (World world) |
void | postToGameThread (NetworkCommand command) |
The interface for the Network system.
Definition at line 11 of file Network.java.
void bubolo.net.Network.connect | ( | InetAddress | serverIpAddress | ) | throws NetworkException, IllegalStateException |
Attempts to connect to the specified IP address. startServer
must be called before calling connect
.
serverIpAddress | the IP address of a server. Note that this isn't necessarily the game server, since clients also connect directly to each other. |
NetworkException | if a network error occurs. |
IllegalStateException | if connect is called before startServer was called. |
Implemented in bubolo.net.NetworkSystem.
void bubolo.net.Network.destroy | ( | ) |
Shuts down the network system.
Implemented in bubolo.net.NetworkSystem.
boolean bubolo.net.Network.isActive | ( | ) |
Returns true if the network is active, or false otherwise.
Implemented in bubolo.net.NetworkSystem.
Referenced by bubolo.net.ConnectionReader.run(), and bubolo.net.Connections.run().
boolean bubolo.net.Network.isGameServer | ( | ) |
Returns true if this player is the game server, or false otherwise. Note that all players run clients and servers, because everyone connects to each other to reduce latency. The official server is only used for certain non-game functionality, such as acting as the central connection point and sending out ip addresses of all players.
Implemented in bubolo.net.NetworkSystem.
void bubolo.net.Network.postToGameThread | ( | NetworkCommand | command | ) |
Runs a NetworkCommand in the game logic thread.
command |
Implemented in bubolo.net.NetworkSystem.
void bubolo.net.Network.reset | ( | ) |
Resets the network system.
Implemented in bubolo.net.NetworkSystem.
void bubolo.net.Network.send | ( | NetworkCommand | command | ) |
Queues a network command to be sent to the other players.
command | the network command to send. |
Implemented in bubolo.net.NetworkSystem.
void bubolo.net.Network.startServer | ( | boolean | isGameServer | ) | throws NetworkException, IllegalStateException |
Identifies this player as the server, and begins accepting connections from other players. startServer
must be called before calling connect
.
isGameServer | true if this player is the game server, or false otherwise. There should only be one game server per game. |
NetworkException | if a network error occurs. |
IllegalStateException | if the server was already started. |
Implemented in bubolo.net.NetworkSystem.
void bubolo.net.Network.update | ( | World | world | ) |
Performs all network system updates. This should be called once per game tick.
world | reference to the game world. |
Implemented in bubolo.net.NetworkSystem.