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

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)
 

Detailed Description

The interface for the Network system.

Author
BU CS673 - Clone Productions

Definition at line 11 of file Network.java.

Member Function Documentation

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.

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.

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.

Returns
true if the network is active.

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.

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

Implemented in bubolo.net.NetworkSystem.

void bubolo.net.Network.postToGameThread ( NetworkCommand  command)

Runs a NetworkCommand in the game logic thread.

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

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

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.

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.

Parameters
worldreference to the game world.

Implemented in bubolo.net.NetworkSystem.