bubolo
 All Classes Namespaces Functions Variables Enumerator
Public Member Functions | Static Public Member Functions | List of all members
bubolo.net.NetworkSystem Class Reference
Inheritance diagram for bubolo.net.NetworkSystem:
bubolo.net.Network

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 ()
 

Detailed Description

Concrete implementation of the network system.

Author
BU CS673 - Clone Productions

Definition at line 17 of file NetworkSystem.java.

Member Function Documentation

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.

Parameters
serverIpAddressthe IP address of a server. Note that this isn't necessarily the game server, since clients also connect directly to each other.
Exceptions
NetworkExceptionif a network error occurs.
IllegalStateExceptionif 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 NetworkSystem bubolo.net.NetworkSystem.getInstance ( )
static

Returns the Network instance.

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.

Returns
true if the network is active.

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.

Returns
true if this player is the game server, or false otherwise.

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.

Parameters
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.

Parameters
commandthe 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.

Parameters
isGameServertrue if this player is the game server, or false otherwise. There should only be one game server per game.
Exceptions
NetworkExceptionif a network error occurs.
IllegalStateExceptionif 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.

Parameters
worldreference to the game world.

Implements bubolo.net.Network.

Definition at line 160 of file NetworkSystem.java.

References bubolo.net.NetworkInformation.MILLIS_PER_TICK.