找到你要的答案

Q:Smartfox iOS - Cannot join room

Q:不能加入房间SmartFox iOS

Here is my RoomSettings

let roomSettings = RoomSettings(name: "room \(rooms.count + 1)")
roomSettings.maxUsers = 10
smartFox.send(CreateRoomRequest(roomSettings: roomSettings, autoJoin: false, roomToLeave: nil))

Join room request

func joinRoom(room : Room, callback : (Result -> ())?)
{
    pendingCallbacks[TaskType.JoinRoom] = callback
    smartFox.send(JoinRoomRequest(id: room.id()))
}

After the room is created, I click on it to join but strange exception occurs and i really don't know what happens

21:07:18,545 ERROR [SFSWorker:Sys:4] v290.SystemReqController     - Cannot find a controller command for request ID: 3
21:07:18,546 WARN  [SFSWorker:Sys:4] v290.SystemReqController     - java.lang.NullPointerException
java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1124)
com.smartfoxserver.v2.controllers.v290.SystemReqController.processRequest(SystemReqController.java:146)
com.smartfoxserver.v2.controllers.v290.SystemReqController.enqueueRequest(SystemReqController.java:119)
com.smartfoxserver.bitswarm.io.protocols.AbstractProtocolCodec.dispatchRequestToController(AbstractProtocolCodec.java:39)
com.smartfoxserver.v2.protocol.SFSProtocolCodec.dispatchRequest(SFSProtocolCodec.java:133)
com.smartfoxserver.v2.protocol.SFSProtocolCodec.onPacketRead(SFSProtocolCodec.java:90)
com.smartfoxserver.v2.protocol.binary.BinaryIoHandler$1.run(BinaryIoHandler.java:477)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)

Could you tell me how to resolve this problem ?

I use smartfox server 2.10.0 and smartfox client ObjC 1.6.0

这是我的roomsettings

let roomSettings = RoomSettings(name: "room \(rooms.count + 1)")
roomSettings.maxUsers = 10
smartFox.send(CreateRoomRequest(roomSettings: roomSettings, autoJoin: false, roomToLeave: nil))

加入房间的要求

func joinRoom(room : Room, callback : (Result -> ())?)
{
    pendingCallbacks[TaskType.JoinRoom] = callback
    smartFox.send(JoinRoomRequest(id: room.id()))
}

创建房间后,我点击它加入,但奇怪的异常发生,我真的不知道会发生什么

21:07:18,545 ERROR [SFSWorker:Sys:4] v290.SystemReqController     - Cannot find a controller command for request ID: 3
21:07:18,546 WARN  [SFSWorker:Sys:4] v290.SystemReqController     - java.lang.NullPointerException
java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1124)
com.smartfoxserver.v2.controllers.v290.SystemReqController.processRequest(SystemReqController.java:146)
com.smartfoxserver.v2.controllers.v290.SystemReqController.enqueueRequest(SystemReqController.java:119)
com.smartfoxserver.bitswarm.io.protocols.AbstractProtocolCodec.dispatchRequestToController(AbstractProtocolCodec.java:39)
com.smartfoxserver.v2.protocol.SFSProtocolCodec.dispatchRequest(SFSProtocolCodec.java:133)
com.smartfoxserver.v2.protocol.SFSProtocolCodec.onPacketRead(SFSProtocolCodec.java:90)
com.smartfoxserver.v2.protocol.binary.BinaryIoHandler$1.run(BinaryIoHandler.java:477)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
java.lang.Thread.run(Thread.java:745)

你能告诉我如何解决这个问题吗?

我用SmartFox服务器和客户端2.10.0 SmartFox objc 1.6.0

answer1: 回答1:

Maybe there is something wrong with the client api, I cannot use the Room Id to join and leave room (If i use room id, that exception will occur). Even though, smartfox document said it's possible.

Now by changing room id to room name in JoinRoomRequest, everything works well

也许客户端API有问题,我不能使用房间ID加入和离开房间(如果我使用房间ID,将发生异常)。尽管SmartFox文件说如果可能的话。

现在通过改变房间ID在joinroomrequest房间的名称,一切顺利

ios  swift  smartfoxserver  smartfox