The QuickJoinGameRequest is used to create a new game on the server, or to join a game that matches the criteria passed in.
That request leads to this response.
This server feature is called the Game Manager. In order to use a game with the Game Manager the game must be registered with the server via the Remote Admin. A game is essentially just a room with one or more plugins associated with it. All games that are managed can be searched using the FindGamesReqest. A game can be joined via QuickJoinGameRequest or by using the JoinGameRequest and specifying a specific game id. You can learn of a game id by someone telling you via various server messaging techniques, or by loading a list of games using the FindGamesRequest and looking at the game ids.
This example shows how to create a fictional game of poker. If the game was registered with the server as PokerGame, and if the game plugin was set up to receive and interpret
the custom EsObject passed in, then this is what the code to create or join such a game would look like.
private var _es:ElectroServer;
private function initialize():void {
_es.engine.addEventListener(MessageType.CreateOrJoinGameResponse.name, onCreateOrJoinGameResponse);
_es.engine.addEventListener(MessageType.JoinRoomEvent.name, onJoinRoomEvent); //create the request
var qjr:QuickJoinGameRequest = new QuickJoinGameRequest(); //gameType is the name of the game as registered on the server
qjr.gameType = "PokerGame"; //zone in which to put the game
qjr.zoneName = "GameZone"; //should the game show up in the room list
qjr.hidden = false; //if true, the game is automatically locked when you join until unlocked
qjr.locked = false; //if true, then the request won't look for an existing game for you to join, it will only create one
qjr.createOnly = false; //optional EsObject of data to pass into the game
var esob:EsObject = new EsObject();
esob.setInteger("potLimit", 2500);
esob.setInteger("tableSize", 8); qjr.gameDetails = esob;
_es.engine.send(qjr);
}
private function onJoinRoomEvent(e:JoinRoomEvent):void {
trace("Joined the game room");
}private function onCreateOrJoinGameResponse(e:CreateOrJoinGameResponse):void {
trace("Joined game: " + e.successful.toString());
}