SFSGameApi.populateInvitations 处的 SmartFox 错误 NullPointerException
Posted
技术标签:
【中文标题】SFSGameApi.populateInvitations 处的 SmartFox 错误 NullPointerException【英文标题】:SmartFox error NullPointerException at SFSGameApi.populateInvitations 【发布时间】:2016-03-31 05:38:52 【问题描述】:我需要一些有关 SmartFox 服务器的帮助。
ISFSGameApi gameAPI = SmartFoxServer.getInstance().getAPIManager().getGameApi();
List<User> invitees = new ArrayList<User>();
invitees.add(invitee);
CreateSFSGameSettings settings = new CreateSFSGameSettings();
settings.setMaxUsers(2);
settings.setMaxVariablesAllowed(5);
settings.setGame(true);
settings.setInvitationExpiryTime(waitingTime);
settings.setMinPlayersToStartGame(2);
settings.setName("rm-" + sender.getName());
settings.setDynamic(true);
settings.setLeaveLastJoinedRoom(false);
settings.setAutoRemoveMode(SFSRoomRemoveMode.WHEN_EMPTY);
settings.setInvitedPlayers(invitees);
try
gameAPI.createGame(getParentExtension().getParentZone(), settings, sender);
catch (SFSCreateRoomException e)
// TODO Auto-generated catch block
e.printStackTrace();
在执行上述代码作为扩展时,我遇到了这个错误。任何想法都值得赞赏。我对java不太熟悉。谢谢
java.lang.NullPointerException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.NullPointerException
Message: *** Null ***
Description: Error while handling client request in extension: Ext: QyServerExtension, Type: JAVA, Lev: ZONE, Zone: Qy ,
Extension Cmd: invite
+--- --- ---+
Stack Trace:
+--- --- ---+
com.smartfoxserver.v2.api.SFSGameApi.populateInvitations(SFSGameApi.java:374)
com.smartfoxserver.v2.api.SFSGameApi.createGame(SFSGameApi.java:153)
com.smartfoxserver.v2.api.SFSGameApi.createGame(SFSGameApi.java:83)
qy.server.GameInvitation.handleClientRequest(GameInvitation.java:56)
com.smartfoxserver.v2.extensions.SFSExtension.handleClientRequest(SFSExtension.java:208)
com.smartfoxserver.v2.controllers.v290.ExtensionReqController.processRequest(ExtensionReqController.java:174)
com.smartfoxserver.v2.controllers.v290.ExtensionReqController$1.run(ExtensionReqController.java:68)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
我的猜测是这与邀请有关,我追踪了“被邀请者”及其用户,还追踪了其他变量并且工作正常。
【问题讨论】:
【参考方案1】:改变了
settings.setMinPlayersToStartGame(2);
到
settings.setMinPlayersToStartGame(1);
而且效果很好。看起来还是很奇怪。我猜。希望它可以帮助某人。
【讨论】:
以上是关于SFSGameApi.populateInvitations 处的 SmartFox 错误 NullPointerException的主要内容,如果未能解决你的问题,请参考以下文章