|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvooga.gameEngine.game.GameRelatedObject
vooga.gameEngine.controller.GameRelatedController
vooga.gameEngine.controller.NetworkController
public class NetworkController
NetworkController
is a subclass of GameRelatedController
and is used to communicate NetworkEvent
s to
GameRelatedObject
s both locally and remotely that are interested
in those events.
NetworkController
will not be enabled in games which do not
support networking, but may still exist. This should be taken into account
when writing game code and methods such as isANetworkGame()
may be
helpful.
NetworkController
also provides a mechanism for mapping players
to GameRelatedObject
s with the #mapPlayerToGameObject(int, Collection
method.
Constructor Summary | |
---|---|
NetworkController()
Default constructor for a NetworkController |
Method Summary | |
---|---|
void |
disconnect()
|
java.util.Collection<java.util.EventListener> |
getLocalPlayerObjects()
Getter method for the Collection mapped to
the local player's player number as given by the
getPlayerNumber() method. |
int |
getPlayerNumber()
Getter method for this instance's player number. |
java.util.List<java.util.EventObject> |
getUserInput()
Simple getter method to obtain the events fired by networked user input. |
boolean |
isANetworkGame()
|
void |
mapBroadCastListener(java.util.EventListener listener)
Maps EventListener s to a broadcast ID which is consistent
across multiple networked machines and thus can be used to have any
player send a BroadcastEvent to a specific
EventListener |
void |
mapPlayerToGameObject(int playerNumber,
java.util.EventListener listener)
Maps player numbers to EventListener s so that events fired
from a particular player's machine can update the state of any
EventListener s that are mapped to that player number. |
void |
networkEventReceived(NetworkEvent e)
Responds to a received NetworkEvent either by sending that
EventObject across the network or by performing an action
locally. |
void |
receiveObject(java.lang.Object object)
Performs the appropriate action when an Object has been received from the server. |
void |
setUp(int playerNumber,
HumanController inputControl,
VoogaGameClient localClient)
Called by network instances of games to setup the framework for networked multiplayer games. |
Methods inherited from class vooga.gameEngine.game.GameRelatedObject |
---|
addEventListener, clearListeners, equals, fire, fire, fire, getEventListeners, getID, getListenerCount, removeEventListener |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NetworkController()
NetworkController
Method Detail |
---|
public void setUp(int playerNumber, HumanController inputControl, VoogaGameClient localClient)
NetworkEvent
s will not be processed.
playerNumber
- The unique player number for the local instance of the gameinputControl
- Used to listen for NetworkEvent
s generated by
user inputpublic int getPlayerNumber()
public boolean isANetworkGame()
public void mapPlayerToGameObject(int playerNumber, java.util.EventListener listener)
EventListener
s so that events fired
from a particular player's machine can update the state of any
EventListener
s that are mapped to that player number.
playerNumber
- The player number to be mapped to a given
EventListener
listener
- The EventListener
which will receive events from
the player with corresponding player numberpublic void mapBroadCastListener(java.util.EventListener listener)
EventListener
s to a broadcast ID which is consistent
across multiple networked machines and thus can be used to have any
player send a BroadcastEvent
to a specific
EventListener
listener
- The EventListener
which will receive broadcast
events.public void networkEventReceived(NetworkEvent e)
NetworkListener
NetworkEvent
either by sending that
EventObject
across the network or by performing an action
locally.
networkEventReceived
in interface NetworkListener
e
- The NetworkEvent
receivedpublic void receiveObject(java.lang.Object object)
INetworkObjectReceiver
receiveObject
in interface INetworkObjectReceiver
public java.util.List<java.util.EventObject> getUserInput()
List
of fired eventspublic java.util.Collection<java.util.EventListener> getLocalPlayerObjects()
Collection
mapped to
the local player's player number as given by the
getPlayerNumber()
method.
GameRelatedObject
representing the local player
which also must be an EventListener
public void disconnect()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |