Now, I'm having trouble sending an ExtensionRequest to my SFSGame. This worked fine when I created a regular game with CreateRoomRequest. Now, however, I get the following error on the server side:
18:54:27,168 WARN [com.smartfoxserver.v2.controllers.ExtensionController-1] controllers.ExtensionController -
com.smartfoxserver.v2.exceptions.SFSExtensionException: No extensions can be invoked: { Zone: MyZone }, RoomId: 4
com.smartfoxserver.v2.controllers.ExtensionController.processRequest(ExtensionController.java:120)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:637)
Create SFSGame:
Code: Select all
btn_quickCreate.addEventListener(MouseEvent.CLICK,onCreateGameClick2);
function onCreateGameClick2(Event:MouseEvent):void {
setAvatarUserVars();
sfs.addEventListener(SFSEvent.ROOM_ADD, onRoomCreated);
sfs.addEventListener(SFSEvent.ROOM_JOIN, onRoomJoin);
sfs.addEventListener(SFSEvent.ROOM_CREATION_ERROR, onRoomCreationError);
// Prepare the settings for a public game
var settings:SFSGameSettings = new SFSGameSettings("game1");
settings.groupId = "game";
settings.maxUsers = 2;
settings.maxSpectators = 8;
settings.isPublic = true;
settings.minPlayersToStartGame = 2;
settings.notifyGameStarted = true;
settings.variables = [new SFSRoomVariable("desc", "Darts game, public")];
// Create the game
sfs.send(new CreateSFSGameRequest(settings));
}
Send extension request to server after creating and joining the room:
Code: Select all
function initGame():void {
// Send extension request to initialize game - check min/max players, start timer/game
var sfsObj:SFSObject = new SFSObject();
sfsObj.putInt("userId", int(Globals.vars.myUserId));
var myExtReq:ExtensionRequest = new ExtensionRequest(PluginConstants.JOIN_GAME, sfsObj, Globals.vars.joinedRoom);
sfs.send(myExtReq);
}
Server side - main extension:
Code: Select all
public class MyCoolGame extends SFSExtension {
public void init() {
addRequestHandler(PluginConstants.JOIN_GAME, JoinGameHandler.class);
}
}
JoinGameHandler:
Code: Select all
public class JoinGameHandler extends BaseClientRequestHandler {
private GameState gameState;
@Override
public void handleClientRequest(User player, ISFSObject params) {
//PLAYER_COUNT++;
trace(">>> JoinGameHandler Initialized <<<");
}
}
What's different between calling a room extension and a SFSGame extension, and what do I need to change in order to get this to work?