| Package | com.electrotank.electroserver4.message.request |
| Class | public class QuickJoinGameRequest |
| Inheritance | QuickJoinGameRequest com.electrotank.electroserver4.message.request.RequestImpl |
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();
| Method | Defined 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 | ||
|
setSearchCriteria(criteria:SearchCriteria):void
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 | |||
| QuickJoinGameRequest | () | constructor |
public function QuickJoinGameRequest()Creates a new instance of the QuickJoinGameRequest class.
| getGameDetails | () | method |
public function getGameDetails():EsObjectThe EsObjec to be used if a game is being created.
ReturnsEsObject —
The EsObjec to be used if a game is being created.
|
| getGameType | () | method |
public function getGameType():StringThe type of game registered with ElectroServer.
ReturnsString — The type of game registered with ElectroServer.
|
| getPassword | () | method |
public function getPassword():StringPassword to be used when joining or creating a game.
ReturnsString — Password to be used when joining or creating a game.
|
| getRealMessage | () | method |
| getSearchCriteria | () | method |
public function getSearchCriteria():SearchCriteriaGets the SearchCriteria class instance.
ReturnsSearchCriteria —
Returns the SearchCriteria class instance.
|
| getZoneName | () | method |
public function getZoneName():StringName of the zone to used when creating a game.
ReturnsString — Name of the zone to use when creating a game.
|
| setGameDetails | () | method |
public function setGameDetails(gameDetails:EsObject):voidThe EsObjec to be used if a game is being created.
ParametersgameDetails:EsObject — The EsObjec to be used if a game is being created.
|
| setGameType | () | method |
public function setGameType(gameType:String):voidGame type as registered on the server.
ParametersgameType:String — The type of game registered with ElectroServer.
|
| setPassword | () | method |
public function setPassword(password:String):voidOptional password to be used when joining a game or creating one.
Parameterspassword:String — Optional password to be used when joining a game or creating one.
|
| setSearchCriteria | () | method |
public function setSearchCriteria(criteria:SearchCriteria):voidThe 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.
Parameterscriteria:SearchCriteria — SearchCriteria class instance.
|
| setZoneName | () | method |
public function setZoneName(zoneName:String):voidSets the name of the zone to create the game in if a game isn't found to join.
ParameterszoneName:String — The name of the zone to create the game in if a game isn't found to join.
|
| validate | () | method |