quickJoinGame

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
vandelpal
Posts: 11
Joined: 25 Oct 2010, 17:14

quickJoinGame

Post by vandelpal »

Why function quickJoinGame in GameApi fire Exception, when I try call it on empty server zone? In my opinion if the zone does not have any room it should return null and not exception.

Code: Select all

findRoomsMathExpression = new MatchExpression(RoomProperties.IS_GAME, BoolMatch.EQUALS, true).and
                                           (RoomProperties.HAS_FREE_PLAYER_SLOTS, BoolMatch.EQUALS, true);

 getGameApi().quickJoinGame(user, findRoomsMathExpression, getZone(), "battle");

Code: Select all


ERROR [com.smartfoxserver.v2.controllers.ExtensionController-1] v2.controllers.ExtensionController     - 
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.IllegalArgumentException
Message: No Room provided for searching.
Description: Error while handling client request in extension: { Ext: XCOMExtension, Type: JAVA, Lev: ZONE, { Zone: XCOMExtension }, {} }
Extension Cmd: MSG_JOINT_TO_BATTLE
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.api.SFSGameApi.quickJoinGame(SFSGameApi.java:252)
com.smartfoxserver.v2.api.SFSGameApi.quickJoinGame(SFSGameApi.java:196)
com.smartfoxserver.v2.api.SFSGameApi.quickJoinGame(SFSGameApi.java:190)
com.smartfoxserver.v2.api.SFSGameApi.quickJoinGame(SFSGameApi.java:184)
sfs2extensions.games.xcom.gamezone.model.proxy.BattleRoomsProxy.jointBattle(BattleRoomsProxy.java:101)
sfs2extensions.games.xcom.gamezone.view.handlers.JointToBattleHandler.handleClientRequest(JointToBattleHandler.java:31)
com.smartfoxserver.v2.extensions.SFSExtension.handleClientRequest(SFSExtension.java:187)
com.smartfoxserver.v2.controllers.ExtensionController.processRequest(ExtensionController.java:137)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

The API expect at least one Room to search, otherwise it doesn't make sense searching for anything. If you don't want to catch the exception (which is actually a RuntimeException, so not mandatory) you could just make a little check.

Code: Select all

if (zone.getRoomCount() == 0) 
// avoid searching...
which is the same as testing if the returned Room is null.
Lapo
--
gotoAndPlay()
...addicted to flash games
vandelpal
Posts: 11
Joined: 25 Oct 2010, 17:14

Post by vandelpal »

This IF should be inside a function quickJoinGame, that function does not fall under the correct parameters. I handed her a MatchExpression and search location(Zone), it should not fall if it did not find any room. Otherwise it seems unreliable.
Post Reply