Packagecom.electrotank.electroserver4.message.request
Classpublic class QuickJoinGameRequest
InheritanceQuickJoinGameRequest Inheritance com.electrotank.electroserver4.message.request.RequestImpl

This class lets you quickly create or join a game using ElectroServer's built-in Game Manager. The game type specified must be registered with ElectroServer (That is not done via the client).
This request first tries to find a game to join. If it doesn't find a game, then it creates one and joins you to it. Here are the fields used to find a game:
setSearchCriteria(SearchCriteria) - Existing games are defined by their game type and by their game details EsObject. The SearchCriteria class lets you specify match requirements used during the server. If you only want to join a game using the IceWorld.xml map, then that can be automated in this way. See the SearchCriteria class for more information.

Here is what is used to create a game if one isn't found:
setGameType(string) - In order for a game to be managed by the Game Manager it must be registered with the server, for instance Chess. That game type is then specified here so the correct game type is used on the server.
setGameDetails(EsObject) - This is an EsObject that is acts as a public property for the game. The game plugin(s) can view and edit this object and other users see it in the game list associated with this game.
setPassword(string) - Optional. If you want the game to be password protected then just set a password during the game creation.
setZoneName(string) - This is the zone in which the game will be created. Any string name will do.


Example
This example shows how to create a new game and capture the CreateOrJoinGameResponse.
    import com.electrotank.electroserver4.ElectroServer;
    import com.electrotank.electroserver4.entities.SearchCriteria;
    import com.electrotank.electroserver4.errors.EsError;
    import com.electrotank.electroserver4.esobject.EsObject;
    import com.electrotank.electroserver4.message.MessageType;
    import com.electrotank.electroserver4.message.request.QuickJoinGameRequest;
    import com.electrotank.electroserver4.message.response.CreateOrJoinGameResponse;
    //
    var es:ElectroServer;//Assume this was created, connection established, and login established already
    //
    function init():void {
        es.addEventListener(MessageType.CreateOrJoinGameResponse, "onCreateOrJoinGameResponse", this);
    }
    function quickJoinGame():void {
        //custom game details that are associtated with the game on the server
        var gameDetails:EsObject = new EsObject();
        gameDetails.setString("Map", "RoughTerrain.xml");
        gameDetails.setInteger("TimeLimit", 100000);
        //Create the search criteria. This is used to try to find a game to join.
        var sc:SearchCriteria = new SearchCriteria();
        sc.setGameType("TankGame");//mandatory
        sc.setGameDetails(gameDetails);//optional. use the game details as a search constraint, and use it below in case a match wasn't found.
        //build the request
        var cgr:QuickJoinGameRequest = new QuickJoinGameRequest();
        cgr.setZoneName("Game Zone");//Used if a game isn't found and one needs to be created.
        cgr.setGameDetails(gameDetails);//Used if a game isn't found and one needs to be created.
        cgr.setGameType("TankGame");//Used if a game isn't found and one needs to be created.
        cgr.setSearchCriteria(sc);//Used to find an existing game
        //send it
        es.send(cgr);
    }
    function onCreateOrJoinGameResponse(e:CreateOrJoinGameResponse):void {
        if (e.getSuccessful()) {
            trace("Joined game");
            var gameDetails:EsObject = e.getGameDetails();
            var gameId:Number = e.getGameId();
        } else {
            trace("Failed to create or join game.");
            var err:EsError = e.getEsError();
            trace(err.getDescription());
        }
    }
    init();
    quickJoinGame();
     



Public Methods
 MethodDefined by
  
Creates a new instance of the QuickJoinGameRequest class.
QuickJoinGameRequest
  
The EsObjec to be used if a game is being created.
QuickJoinGameRequest
  
getGameType():String
The type of game registered with ElectroServer.
QuickJoinGameRequest
  
getPassword():String
Password to be used when joining or creating a game.
QuickJoinGameRequest
  
QuickJoinGameRequest
  
Gets the SearchCriteria class instance.
QuickJoinGameRequest
  
getZoneName():String
Name of the zone to used when creating a game.
QuickJoinGameRequest
  
setGameDetails(gameDetails:EsObject):void
The EsObjec to be used if a game is being created.
QuickJoinGameRequest
  
setGameType(gameType:String):void
Game type as registered on the server.
QuickJoinGameRequest
  
setPassword(password:String):void
Optional password to be used when joining a game or creating one.
QuickJoinGameRequest
  
The class used to inform the Game Manager what type of game to look for.
QuickJoinGameRequest
  
setZoneName(zoneName:String):void
Sets the name of the zone to create the game in if a game isn't found to join.
QuickJoinGameRequest
  
QuickJoinGameRequest
Constructor detail
QuickJoinGameRequest()constructor
public function QuickJoinGameRequest()

Creates a new instance of the QuickJoinGameRequest class.

Method detail
getGameDetails()method
public function getGameDetails():EsObject

The EsObjec to be used if a game is being created.

Returns
EsObject — The EsObjec to be used if a game is being created.
getGameType()method 
public function getGameType():String

The type of game registered with ElectroServer.

Returns
String — The type of game registered with ElectroServer.
getPassword()method 
public function getPassword():String

Password to be used when joining or creating a game.

Returns
String — Password to be used when joining or creating a game.
getRealMessage()method 
public override function getRealMessage():Message

Returns
Message
getSearchCriteria()method 
public function getSearchCriteria():SearchCriteria

Gets the SearchCriteria class instance.

Returns
SearchCriteria — Returns the SearchCriteria class instance.
getZoneName()method 
public function getZoneName():String

Name of the zone to used when creating a game.

Returns
String — Name of the zone to use when creating a game.
setGameDetails()method 
public function setGameDetails(gameDetails:EsObject):void

The EsObjec to be used if a game is being created.

Parameters
gameDetails:EsObject — The EsObjec to be used if a game is being created.
setGameType()method 
public function setGameType(gameType:String):void

Game type as registered on the server.

Parameters
gameType:String — The type of game registered with ElectroServer.
setPassword()method 
public function setPassword(password:String):void

Optional password to be used when joining a game or creating one.

Parameters
password:String — Optional password to be used when joining a game or creating one.
setSearchCriteria()method 
public function setSearchCriteria(criteria:SearchCriteria):void

The class used to inform the Game Manager what type of game to look for. Game type and specific fields on the game details object can be used to limit the search.

Parameters
criteria:SearchCriteria — SearchCriteria class instance.
setZoneName()method 
public function setZoneName(zoneName:String):void

Sets the name of the zone to create the game in if a game isn't found to join.

Parameters
zoneName:String — The name of the zone to create the game in if a game isn't found to join.
validate()method 
public override function validate():ValidationResponse

Returns
ValidationResponse