Starting or Joining a game using the QuickJoinOrCreateRoomRequest

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

Moderators: Lapo, Bax

justbake
Posts: 1
Joined: 07 Nov 2022, 00:22

Starting or Joining a game using the QuickJoinOrCreateRoomRequest

Postby justbake » 07 Nov 2022, 00:26

Hello,

Everytime I run this

Code: Select all

public void QuickJoin()
       {
          if(connection.IsConnected && login.IsLoggedIn){
             RPGArenaUser user = ((RPGArenaUser)(NetworkManager.Instance.login.user));
             MatchExpression exp = new MatchExpression("level", NumberMatch.GREATER_THAN, user.level - 10).And("level", NumberMatch.LESS_THAN, user.level + 10);
   
             // Set the Room settings to create a new Room if a matching one is not found
             RoomSettings settings = new RoomSettings($"{user.name}_{new System.Random().Next()}_Game");
             settings.GroupId = "Games";
             settings.IsGame = true;
             settings.MaxUsers = 2;
   
             // Set requirements to allow users find the Room (see match expression above) in Room Variables
             List<RoomVariable> roomVars = new List<RoomVariable>();
             roomVars.Add(new SFSRoomVariable("level", user.level));
             settings.Variables = roomVars;
   
             Debug.Log($"{user}, {user.level} {exp}, {settings}");
   
             // Search (or create) and join a public Room within the "games" Group
             connection.GetSfsClient().Send(new QuickJoinOrCreateRoomRequest(exp, new List<string>(){"Games"}, settings));
          }
       }


I get this log on the server and the room isn't created

Code: Select all

06 Nov 2022
20:30:44,941   ERROR   SFSWorker:Sys:3   controllers.v290.SystemReqController   Cannot find a controller command for request ID: 31
06 Nov 2022
20:30:44,942   WARN   SFSWorker:Sys:3   controllers.v290.SystemReqController   java.lang.NullPointerException
   java.util.concurrent.ConcurrentHashMap.putVal(ConcurrentHashMap.java:1011)
   java.util.concurrent.ConcurrentHashMap.put(ConcurrentHashMap.java:1006)
   com.smartfoxserver.v2.controllers.v290.SystemReqController.processRequest(SystemReqController.java:172)
   com.smartfoxserver.v2.controllers.v290.SystemReqController.enqueueRequest(SystemReqController.java:145)
   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:1149)
   java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
   java.lang.Thread.run(Thread.java:750)


Is there a setting I need to change or something?
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Starting or Joining a game using the QuickJoinOrCreateRoomRequest

Postby Lapo » 07 Nov 2022, 08:27

Hi,
it looks like you might be running an older version of the server which doesn't support the request you're sending.
The QuickJoinOrCreateRoom request was introduced in SFS2X 2.18.2

If you're running version 2.18.0 make sure to download the latest patch here:
https://www.smartfoxserver.com/download/sfs2x#p=updates

Otherwise install 2.18.0 first then apply the latest update:
https://www.smartfoxserver.com/download ... =installer

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Google [Bot] and 53 guests