cz.cuni.amis.pogamut.ut2004.server.impl
Class UT2004Server

java.lang.Object
  extended by cz.cuni.amis.pogamut.base.agent.impl.AbstractAgent
      extended by cz.cuni.amis.pogamut.base.agent.impl.AbstractObservingAgent<WORLD_VIEW>
          extended by cz.cuni.amis.pogamut.base.agent.impl.AbstractGhostAgent<WORLD_VIEW,ACT>
              extended by cz.cuni.amis.pogamut.base.server.AbstractWorldServer<WORLD_VIEW,ACT,IUT2004Bot>
                  extended by cz.cuni.amis.pogamut.ut2004.server.impl.AbstractUT2004Server<UT2004WorldView,IAct>
                      extended by cz.cuni.amis.pogamut.ut2004.server.impl.UT2004Server
All Implemented Interfaces:
IAgent, IGhostAgent, IObservingAgent, IComponent, IComponentAware, IControllable, IWorldAgentsObserver<IUT2004Bot>, IWorldServer<IUT2004Bot>, IUnrealServer<IUT2004Bot>, IUT2004Server
Direct Known Subclasses:
UT2004Analyzer

public class UT2004Server
extends AbstractUT2004Server<UT2004WorldView,IAct>
implements IUT2004Server


Nested Class Summary
 class UT2004Server.MapChangeFuture
           
 
Field Summary
protected  boolean changingMap
           
protected  int changingMapAttempt
           
protected  java.lang.Object changingMapMutex
           
static int MAP_CHANGE_CONNECT_INTERVAL_MILLIS
           
protected  UT2004Server.MapChangeFuture mapChangeFuture
           
protected  IWorldEventListener<MapListObtained> mapListListener
           
static int MAX_CHANGING_MAP_ATTEMPTS
          How many times we're going to try to connect to the GB2004 before declaring that the change-map has failed.
protected  IWorldEventListener<PlayerJoinsGame> playerJoinsListener
           
protected  java.lang.String targetMap
           
 
Fields inherited from class cz.cuni.amis.pogamut.base.server.AbstractWorldServer
worldAddress
 
Fields inherited from class cz.cuni.amis.pogamut.base.agent.impl.AbstractAgent
events, INTROSPECTION_ROOT_NAME, log
 
Constructor Summary
UT2004Server(UT2004AgentParameters params, IAgentLogger agentLogger, IComponentBus bus, SocketConnection connection, UT2004WorldView worldView, IAct act)
           
 
Method Summary
 UT2004AgentParameters getParams()
          Returns parameters that were passed into the agent during the construction.
protected  void reset()
          Called during stop/kill/reset events.
 java.util.concurrent.Future<java.lang.Boolean> setGameMap(java.lang.String map)
          Method that initiates map-change.
protected  void startAgent()
          Called during start() method - override to provide custom starting behavior of the agent.
protected  void startPausedAgent()
          Called during startPaused() method - override to provide custom starting-paused behavior of the agent.
 
Methods inherited from class cz.cuni.amis.pogamut.ut2004.server.impl.AbstractUT2004Server
connectNativeBot, createPasswordReply, getAgents, getAvailableMaps, getGameInfo, getGameSpeedFlag, getMap, getMapName, getMutators, getNativeAgents, getPasswordReply, getPlayers, getWorldView, killAgent, readyCommandRequested, resetAgent, setAddress, setPassword, stopAgent
 
Methods inherited from class cz.cuni.amis.pogamut.base.server.AbstractWorldServer
getWorldAddress
 
Methods inherited from class cz.cuni.amis.pogamut.base.agent.impl.AbstractGhostAgent
getAct
 
Methods inherited from class cz.cuni.amis.pogamut.base.agent.impl.AbstractAgent
addDependency, addDependency, addDependency, addJMXComponents, awaitState, awaitState, componentFatalError, componentStarted, componentStarted, componentStopped, componentStopping, createAgentJMX, createIntrospection, equals, getComponentId, getEventBus, getIntrospection, getJMX, getLog, getLogger, getName, getState, hashCode, inState, kill, notInState, pause, pauseAgent, preKillAgent, preStopAgent, resetEvent, resume, resumeAgent, setState, start, startPaused, stop, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface cz.cuni.amis.pogamut.ut2004.server.IUT2004Server
connectNativeBot, getAvailableMaps, getGameSpeedFlag, getMap, getMapName, getMutators, getNativeAgents, getPlayers, setAddress
 
Methods inherited from interface cz.cuni.amis.pogamut.base.server.IWorldServer
getWorldAddress
 
Methods inherited from interface cz.cuni.amis.pogamut.base.server.IWorldAgentsObserver
getAgents
 
Methods inherited from interface cz.cuni.amis.pogamut.base.agent.IGhostAgent
getAct
 
Methods inherited from interface cz.cuni.amis.pogamut.base.agent.IObservingAgent
getWorldView
 
Methods inherited from interface cz.cuni.amis.pogamut.base.agent.IAgent
getComponentId, getIntrospection, getLogger, getName, getState, kill, pause, resume, start, startPaused, stop
 
Methods inherited from interface cz.cuni.amis.pogamut.base.component.IComponentAware
getEventBus
 

Field Detail

MAX_CHANGING_MAP_ATTEMPTS

public static final int MAX_CHANGING_MAP_ATTEMPTS
How many times we're going to try to connect to the GB2004 before declaring that the change-map has failed.

See Also:
Constant Field Values

MAP_CHANGE_CONNECT_INTERVAL_MILLIS

public static final int MAP_CHANGE_CONNECT_INTERVAL_MILLIS
See Also:
Constant Field Values

playerJoinsListener

protected IWorldEventListener<PlayerJoinsGame> playerJoinsListener

mapListListener

protected IWorldEventListener<MapListObtained> mapListListener

changingMapMutex

protected java.lang.Object changingMapMutex

changingMap

protected boolean changingMap

changingMapAttempt

protected int changingMapAttempt

targetMap

protected java.lang.String targetMap

mapChangeFuture

protected UT2004Server.MapChangeFuture mapChangeFuture
Constructor Detail

UT2004Server

@Inject
public UT2004Server(UT2004AgentParameters params,
                           IAgentLogger agentLogger,
                           IComponentBus bus,
                           SocketConnection connection,
                           UT2004WorldView worldView,
                           IAct act)
Method Detail

getParams

public UT2004AgentParameters getParams()
Returns parameters that were passed into the agent during the construction.

This is a great place to parametrize your agent. Note that you may pass arbitrary subclass of UT2004AgentParameters to the constructor/factory/runner and pick them up here.

Returns:
parameters

startAgent

protected void startAgent()
Description copied from class: AbstractAgent
Called during start() method - override to provide custom starting behavior of the agent.

WARNING: DO NOT CALL ON YOUR OWN, ALWAYS USE PUBLIC INTERFACE (start()), but that should not be needed!

If you override this method don't forget to call super.startAgent() as the first method.

Overrides:
startAgent in class AbstractUT2004Server<UT2004WorldView,IAct>

startPausedAgent

protected void startPausedAgent()
Description copied from class: AbstractAgent
Called during startPaused() method - override to provide custom starting-paused behavior of the agent.

WARNING: DO NOT CALL ON YOUR OWN, ALWAYS USE PUBLIC INTERFACE (startPaused()), but that should not be needed!

If you override this method don't forget to call super.startPausedAgent() as the first method.

Overrides:
startPausedAgent in class AbstractUT2004Server<UT2004WorldView,IAct>

reset

protected void reset()
Description copied from class: AbstractUT2004Server
Called during stop/kill/reset events.

Overrides:
reset in class AbstractUT2004Server<UT2004WorldView,IAct>

setGameMap

public java.util.concurrent.Future<java.lang.Boolean> setGameMap(java.lang.String map)
                                                          throws MapChangeException
Description copied from interface: IUT2004Server
Method that initiates map-change. It returns future that describes the result.

Note that the object must restart itself in order to reconnect to the new server.

Specified by:
setGameMap in interface IUnrealServer<IUT2004Bot>
Specified by:
setGameMap in interface IUT2004Server
Throws:
MapChangeException