cz.cuni.amis.pogamut.udk.server.impl
Class AbstractUDKServer<WORLD_VIEW extends IWorldView,ACT extends IAct>

Package class diagram package AbstractUDKServer
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,IUDKBot>
                  extended by cz.cuni.amis.pogamut.udk.server.impl.AbstractUDKServer<WORLD_VIEW,ACT>
All Implemented Interfaces:
IAgent, IGhostAgent, IObservingAgent, IComponent, IComponentAware, IControllable, IWorldAgentsObserver<IUDKBot>, IWorldServer<IUDKBot>, IUDKServer, IUnrealServer<IUDKBot>
Direct Known Subclasses:
UDKServer

public abstract class AbstractUDKServer<WORLD_VIEW extends IWorldView,ACT extends IAct>
extends AbstractWorldServer<WORLD_VIEW,ACT,IUDKBot>
implements IUDKServer

Abstract class - ancestor of all UT2004 server controls.

It counts with GameBots2004 protocol therefore taking care of:

  1. ReadyCommandRequest - sending automatically ready(), override readyCommandRequested() if you're not comfortable with this
  2. Password - when password is requested it calls method createPasswordReply()

Also introducing user-method for setting up custom worldview listeners that is called before Ready message is sent - prePrepareServer().

You may use setPassword() method to specify the password before starting the agent.

Author:
Jimmy

Field Summary
 
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, LOG_CATEGORY_NAME
 
Constructor Summary
AbstractUDKServer(IAgentId agentId, IAgentLogger agentLogger, IComponentBus bus, SocketConnection connection, WORLD_VIEW worldView, ACT act)
           
 
Method Summary
 void connectNativeBot(String botName, String botType)
          Connects a UT native bot to the current map.
protected  PasswordReply createPasswordReply()
          This method is called whenever the Password event is caught telling us the world is locked and is requiring a password.
 cz.cuni.amis.utils.collections.ObservableCollection<IUDKBot> getAgents()
           
 Collection<MapList> getAvailableMaps()
           
 GameInfo getGameInfo()
           
 cz.cuni.amis.utils.flag.Flag<Double> getGameSpeedFlag()
          The flag raises events even when the game speed was changed by another UTServer instance or directly in game.
 UDKMap getMap()
          Get current map from the server
 String getMapName()
           
 List<Mutator> getMutators()
          Reeturns list of all mutators available on the server.
 cz.cuni.amis.utils.collections.ObservableCollection<? extends NativeUDKBotAdapter> getNativeAgents()
          Returns list of all non pogamut players connected to the game server.
 PasswordReply getPasswordReply()
          Instance of the password reply command that was sent upon receivieng request for the password (the world is locked).
 cz.cuni.amis.utils.collections.ObservableCollection<Player> getPlayers()
          Returns list of all players connected to the game server.
 WORLD_VIEW getWorldView()
           
protected  void killAgent()
           
protected  void readyCommandRequested()
          This method is called whenever HelloBot message is parsed - the GameBots2004 is awaiting the bot to reply with Ready command to begin the handshake.
protected  void reset()
          Called during stop/kill/reset events.
protected  void resetAgent()
           
 void setAddress(String host, int port)
          Sets the address of the server to different location - does not automatically reconnect, use IAgent.stop() and IAgent.start().
 void setPassword(String password)
          Specify the password that should be used if required by the world.
protected  void startAgent()
           
protected  void 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, startPausedAgent, 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.udk.server.IUDKServer
setGameMap
 
Methods inherited from interface cz.cuni.amis.pogamut.base.server.IWorldServer
getWorldAddress
 
Methods inherited from interface cz.cuni.amis.pogamut.base.agent.IGhostAgent
getAct
 
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
 

Constructor Detail

AbstractUDKServer

@Inject
public AbstractUDKServer(IAgentId agentId,
                                IAgentLogger agentLogger,
                                IComponentBus bus,
                                SocketConnection connection,
                                WORLD_VIEW worldView,
                                ACT act)
Method Detail

setAddress

public void setAddress(String host,
                       int port)
Description copied from interface: IUDKServer
Sets the address of the server to different location - does not automatically reconnect, use IAgent.stop() and IAgent.start().

Specified by:
setAddress in interface IUDKServer
Specified by:
setAddress in interface IUnrealServer<IUDKBot>

setPassword

public void setPassword(String password)
Specify the password that should be used if required by the world.

Parameters:
password -

readyCommandRequested

protected void readyCommandRequested()
This method is called whenever HelloBot message is parsed - the GameBots2004 is awaiting the bot to reply with Ready command to begin the handshake.


getPasswordReply

public PasswordReply getPasswordReply()
Instance of the password reply command that was sent upon receivieng request for the password (the world is locked).

If null the password was not required by the time the bot connected to the world.

Returns:

createPasswordReply

protected PasswordReply createPasswordReply()
This method is called whenever the Password event is caught telling us the world is locked and is requiring a password.

May return null - in that case an empty password is sent to the server (which will probably result in closing the connection and termination of the agent).

This message is then saved to private field passwordReply and is accessible via getPasswordReply() method if required to be probed during the bot's runtime.

Note that if setPassword() method is called before this one it will use provided password via that method.


getGameInfo

public GameInfo getGameInfo()

getWorldView

public WORLD_VIEW getWorldView()
Specified by:
getWorldView in interface IObservingAgent
Overrides:
getWorldView in class AbstractObservingAgent<WORLD_VIEW extends IWorldView>

getAvailableMaps

public Collection<MapList> getAvailableMaps()
Specified by:
getAvailableMaps in interface IUDKServer
Specified by:
getAvailableMaps in interface IUnrealServer<IUDKBot>
Returns:
List of all maps available on the UT server

getGameSpeedFlag

public cz.cuni.amis.utils.flag.Flag<Double> getGameSpeedFlag()
Description copied from interface: IUDKServer
The flag raises events even when the game speed was changed by another UTServer instance or directly in game.

Specified by:
getGameSpeedFlag in interface IUDKServer
Specified by:
getGameSpeedFlag in interface IUnrealServer<IUDKBot>
Returns:
Speed of the game.

getMapName

public String getMapName()
Specified by:
getMapName in interface IUDKServer
Specified by:
getMapName in interface IUnrealServer<IUDKBot>
Returns:
Name of the current map.

getPlayers

public cz.cuni.amis.utils.collections.ObservableCollection<Player> getPlayers()
Description copied from interface: IUDKServer
Returns list of all players connected to the game server. The difference compared to the getAgents() method is that this method can return even the native bots, human players etc.

Specified by:
getPlayers in interface IUDKServer
Specified by:
getPlayers in interface IUnrealServer<IUDKBot>
Returns:
List of all players on the server.

getMutators

public List<Mutator> getMutators()
Description copied from interface: IUDKServer
Reeturns list of all mutators available on the server. Mutators can be used to modify the game (eg. disable weapons, change game speed).

Specified by:
getMutators in interface IUDKServer
Specified by:
getMutators in interface IUnrealServer<IUDKBot>
Returns:
List of all mutators available on the server.

getAgents

public cz.cuni.amis.utils.collections.ObservableCollection<IUDKBot> getAgents()
Specified by:
getAgents in interface IWorldAgentsObserver<IUDKBot>

getNativeAgents

public cz.cuni.amis.utils.collections.ObservableCollection<? extends NativeUDKBotAdapter> getNativeAgents()
Description copied from interface: IUDKServer
Returns list of all non pogamut players connected to the game server. Collection contains NativeBotAdapter classes, this means that you can deal with the players like with Pogamut agents.

Specified by:
getNativeAgents in interface IUDKServer
Specified by:
getNativeAgents in interface IUnrealServer<IUDKBot>
Returns:
List of all players on the server.

connectNativeBot

public void connectNativeBot(String botName,
                             String botType)
Description copied from interface: IUDKServer
Connects a UT native bot to the current map.

Specified by:
connectNativeBot in interface IUDKServer
Specified by:
connectNativeBot in interface IUnrealServer<IUDKBot>

getMap

public UDKMap getMap()
Description copied from interface: IUDKServer
Get current map from the server

Specified by:
getMap in interface IUDKServer
Specified by:
getMap in interface IUnrealServer<IUDKBot>
Returns:
Map of current level.

reset

protected void reset()
Called during stop/kill/reset events.


resetAgent

protected void resetAgent()
Overrides:
resetAgent in class AbstractAgent

stopAgent

protected void stopAgent()
Overrides:
stopAgent in class AbstractAgent

killAgent

protected void killAgent()
Overrides:
killAgent in class AbstractAgent

startAgent

protected void startAgent()
Overrides:
startAgent in class AbstractAgent


Copyright © 2014 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.