Player create room but not auto join

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

tusat
Posts: 2
Joined: 11 Aug 2020, 09:21

Player create room but not auto join

Postby tusat » 11 Aug 2020, 09:37

Hi, i have an problem with player not auto join room after create game room, is it new API work like that, or is it an issue ?
Can someone help please, thanks.

Client API: 1.7.13
Server version: 2.16.0

Create room code:

Code: Select all

            p_initVariables = new List<RoomVariable>();
            p_initVariables.Add(new SFSRoomVariable(SFSVariable.ROOM_PLAYING, false));  //SFSVariable.ROOM_PLAYING = "rp"
           
            RoomSettings settings = new RoomSettings(p_roomName);
            settings.IsGame = true;
            settings.GroupId = "battlearena";
            settings.AllowOwnerOnlyInvitation = false;
            settings.MaxUsers = (short)p_maxUser;
            settings.MaxVariables = 100;
            settings.Password = p_password == null ? "" : p_password;
            settings.Permissions = new RoomPermissions();
            settings.Permissions.AllowPasswordStateChange = true;
            settings.Permissions.AllowPublicMessages = true;
            settings.Permissions.AllowResizing = true;
            settings.Variables = p_initVariables;

            Log("Create game room: " + p_roomName);
            sfs.Send(new CreateRoomRequest(settings));


Create room worked fine, i got ROOM_ADD event success, but the player created room not auto join room. I checked on AdminTool and see that the created game room show up with correct owner (player id), but no user in room.
Note that after create room, if i can join room manually, it worked fine. But what i want to auto join room, because other player can join that room first and cause the creator cant join his room.
Thanks
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Player create room but not auto join

Postby Lapo » 11 Aug 2020, 10:18

Hi,
yes the problem is in your call. If you want the user to auto-join the Room just created you need to pass an extra boolean.

As per the client C# API documentation (valid for all other languages):
http://docs2x.smartfoxserver.com/api-do ... 9624c9.htm
there are three constructors for the CreateRoomRequest object.

The second (bool) parameter can be passed as true to specify that you want to be auto-joined.
In other words:

Code: Select all

sfs.Send(new CreateRoomRequest(settings, true));

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
tusat
Posts: 2
Joined: 11 Aug 2020, 09:21

Re: Player create room but not auto join

Postby tusat » 11 Aug 2020, 11:12

It's my bad that i didn't notice there are other params in CreateRoomRequest.
Worked now! Thanks.

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 29 guests