Password of Private Room

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
sunny
Posts: 19
Joined: 04 Aug 2014, 04:22

Password of Private Room

Post by sunny »

Hi,

I am trying to create private rooms, but it failed.
It keeps returning error: com.smartfoxserver.v2.exceptions.SFSJoinRoomException: Join Error - Room password is wrong.
I've make sure the password for joining room is the same as the password set during room creation.

I've kept the password to be a constant value of "abc".

Code: Select all

SFSGameSettings settings = new SFSGameSettings(roomName);
settings.Password = "abc";
However, the password traced from the "init()" method of the room extension in the server is different every time.
Two of the passwords traced from server are:
ZBKtrdOSuHcXlIXa1444118913084
jnqexikZPMyQnsJB1444119869952

How can I set the correct room password? Do I miss anything? Thanks.

System information:
client: C# API 1.6.2
server: SmartFoxServer 2X 2.10.0

The private room is created by those lines:

Code: Select all

SFSGameSettings settings = new SFSGameSettings(roomName);
settings.MaxUsers = 2;
settings.MaxSpectators = 0;
settings.IsPublic = false;
settings.Password = "abc";

Sfs2X.Entities.User opponent = smartFox.UserManager.GetUserById(opponentID);
List<object> invitedUsers = new List<object>();
invitedUsers.Add(smartFox.MySelf);
invitedUsers.Add(opponent);
settings.InvitedPlayers = invitedUsers;

settings.MinPlayersToStartGame = 2;
settings.NotifyGameStarted = true;

//set room extension
settings.Extension = new RoomExtension("xxx", "xxx");
		
settings.GroupId = GetGroupId();
settings.IsGame = true;

smartFox.Send(new CreateSFSGameRequest(settings));
Join room request:

Code: Select all

smartFox.Send(new JoinRoomRequest(roomID, "abc"));
Thanks
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Password of Private Room

Post by Lapo »

Couple of things are not clear:

1) Are you sending the JoinRoomRequest from client side? If so the password must be specified there and it must match the server password including upper/lower case

2) This I don't understand:
However, the password traced from the "init()" method of the room extension in the server is different every time.
Two of the passwords traced from server are:
ZBKtrdOSuHcXlIXa1444118913084
jnqexikZPMyQnsJB1444119869952
I have no idea what this is. Isn't your Room password "abc"?

You just need to create a Room with isPrivate(true) and a password="abc"

Then from client side you do this:

Code: Select all

sfs.Send(new JoinRoomRequest("MyRoom", "abc"));
Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
sunny
Posts: 19
Joined: 04 Aug 2014, 04:22

Re: Password of Private Room

Post by sunny »

Thanks Lapo.

1) Yah, I'm using JoinRoomRequest, and the password is set to "abc".

The password of the room created for the player to join, is also set to "abc" in the client side.
The room is set to private.
However, I cannot join the room created. It returns wrong room password error.

2) The password traced from server is different every time when creating a new room, although I've set the password of SFSGameSettings to "abc".

Thanks.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Password of Private Room

Post by Lapo »

Ah, that explains it. :)
SFSGame Rooms work differently. They are invitation based, you can't join them manually and the password is auto-generated by the server.

You should probably clarify your use case. If you're trying to create a private game Room that users can join manually then just create a normal SFSRoom with the isGame=true flag. (SFSApi.createRoom...)

SFSGameRoom objects provide far more advanced features for matchmaking based on invitations. If you need this then you don't have to join the Room manually.
Please make sure to read the details here:
http://docs2x.smartfoxserver.com/Advanc ... s/game-api

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
sunny
Posts: 19
Joined: 04 Aug 2014, 04:22

Re: Password of Private Room

Post by sunny »

ic, that means I have to use CreateRoomRequest instead of CreateSFSGameRequest for creating private room and joining manually.
Thanks Lapo.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Password of Private Room

Post by Lapo »

Yes,
Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply