Public Member Functions | |
boolean | isActive () |
boolean | isGameServer () |
void | destroy () |
void | connect (InetAddress serverIpAddress) throws IllegalStateException, NetworkException |
void | startServer (boolean isGameServer) throws IllegalStateException, NetworkException |
void | send (NetworkCommand command) |
void | update (World world) |
void | postToGameThread (NetworkCommand command) |
void | reset () |
Static Public Member Functions | |
static NetworkSystem | getInstance () |
Concrete implementation of the network system.
Definition at line 17 of file NetworkSystem.java.
void bubolo.net.NetworkSystem.connect | ( | InetAddress | serverIpAddress | ) | throws IllegalStateException, NetworkException |
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. |
Implements bubolo.net.Network.
Definition at line 95 of file NetworkSystem.java.
References bubolo.net.NetworkInformation.GAME_PORT.
void bubolo.net.NetworkSystem.destroy | ( | ) |
Shuts down the network system.
Implements bubolo.net.Network.
Definition at line 78 of file NetworkSystem.java.
Referenced by bubolo.net.NetworkSystem.reset().
|
static |
Returns the Network instance.
Definition at line 41 of file NetworkSystem.java.
boolean bubolo.net.NetworkSystem.isActive | ( | ) |
Returns true if the network is active, or false otherwise.
Implements bubolo.net.Network.
Definition at line 66 of file NetworkSystem.java.
boolean bubolo.net.NetworkSystem.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.
Implements bubolo.net.Network.
Definition at line 72 of file NetworkSystem.java.
Referenced by bubolo.net.NetworkSystem.startServer().
void bubolo.net.NetworkSystem.postToGameThread | ( | NetworkCommand | command | ) |
Runs a NetworkCommand in the game logic thread.
command |
Implements bubolo.net.Network.
Definition at line 180 of file NetworkSystem.java.
void bubolo.net.NetworkSystem.reset | ( | ) |
Resets the network system.
Implements bubolo.net.Network.
Definition at line 186 of file NetworkSystem.java.
References bubolo.net.NetworkSystem.destroy().
void bubolo.net.NetworkSystem.send | ( | NetworkCommand | command | ) |
Queues a network command to be sent to the other players.
command | the network command to send. |
Implements bubolo.net.Network.
Definition at line 154 of file NetworkSystem.java.
void bubolo.net.NetworkSystem.startServer | ( | boolean | isGameServer | ) | throws IllegalStateException, NetworkException |
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. |
Implements bubolo.net.Network.
Definition at line 133 of file NetworkSystem.java.
References bubolo.net.NetworkInformation.GAME_PORT, and bubolo.net.NetworkSystem.isGameServer().
void bubolo.net.NetworkSystem.update | ( | World | world | ) |
Performs all network system updates. This should be called once per game tick.
world | reference to the game world. |
Implements bubolo.net.Network.
Definition at line 160 of file NetworkSystem.java.
References bubolo.net.NetworkInformation.MILLIS_PER_TICK.