SFSGame and Room password.

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

Post Reply
User avatar
aaulia
Posts: 31
Joined: 28 May 2011, 18:50

SFSGame and Room password.

Post by aaulia »

Hey guys, it's been a while, I'm doing SFS2X again :). Anyway, need to confirm something, since I can't seem to find this in the doc (sorry if I missed it). Can I set password for SFSGame room? I've tried creating both a Room (with isGame = true) and an SFSGame, both with identical settings (other than the SFSGame specific settings ofc). On a normal Room with isGame = true, the password is set, OTOH on SFSGame, the password is null.

Here is the relevant code (room creation from client side).

Code: Select all

            var roomName:String = txt_roomName.text;
            var password:String = txt_password.text;
            var userSize:int    = cbx_userSize.selectedItem as int;
            
            if (roomName == '' || userSize < gameType.minUser || userSize > gameType.maxUser) {
                return;
            }
            
            var permissions:RoomPermissions = new RoomPermissions();
            var extension  :RoomExtension   = new RoomExtension('*******', 'com.*******.room.*****.RoomExtension');
            var settings   :SFSGameSettings = new SFSGameSettings(roomName);
            
            permissions.allowNameChange          = false;
            permissions.allowPasswordStateChange = false;
            permissions.allowPublicMessages      = true;
            permissions.allowResizing            = false;
            
            //
            // General room settings
            //
            
            settings.groupId               = gameType.groupId;
            settings.isGame                = true;
            settings.maxUsers              = userSize;
            settings.password              = password;
            settings.permissions           = permissions;
            settings.extension             = extension;
            
            //
            // SFSGame room settings
            //
            
            settings.isPublic              = true;
            settings.minPlayersToStartGame = userSize;
            settings.notifyGameStarted     = true;
            
            smartfox.addEventListener(SFSEvent.ROOM_CREATION_ERROR, onRoomCreationError);
            smartfox.send(new CreateSFSGameRequest(settings));
If I change settings to RoomSettings and CreateSFSGameRequest to CreateRoomRequest, the password setting works.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFSGame and Room password.

Post by Lapo »

SFSGames can be public or private. A public one will require no password, a private one will use a password, although users will not need to input the password directly.

This is because in a private game you invite people that you want to play with. The invited players will be allowed to join the room automatically while anyone else trying to join (and not invited) won't be able to enter.

More details are found here:
http://docs2x.smartfoxserver.com/Advanc ... s/game-api

cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
aaulia
Posts: 31
Joined: 28 May 2011, 18:50

Re: SFSGame and Room password.

Post by aaulia »

Hi Lapo thanks for the response, and sorry it took a while for me to reply.

So first, please correct me if I'm wrong, in private SFSGame, it's a requirement to supply list of players to be invited (which include the room creator?) or room(s) name/id where the server can broadcast an invite requests to all user in it.

After talking about it, we're okay with the invite requirement, and actually it make sense. But, we would like to delay the inviting process until the creator successfully create the room instead of before he/she create the room (as a requirement). Would setting minPlayerToStart to 1 and only include oneself in the invite list would suffice in creating an SFSGame with one player, which then he can invite other user in?

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

Re: SFSGame and Room password.

Post by Lapo »

aaulia wrote:Hi Lapo thanks for the response, and sorry it took a while for me to reply.

So first, please correct me if I'm wrong, in private SFSGame, it's a requirement to supply list of players to be invited (which include the room creator?) or room(s) name/id where the server can broadcast an invite requests to all user in it.
Not necessarily. You may start a private game for 3 players (yourself included) but not provide a specific list of people to invite. Instead you can supply a matchExpression to find other players that should be invited.

Also you don't need to invite the creator itself. He's automatically joined in the Room as player #1.
After talking about it, we're okay with the invite requirement, and actually it make sense. But, we would like to delay the inviting process until the creator successfully create the room instead of before he/she create the room (as a requirement).
That's what is already happening.
First the Room is created and the owner is joined. Then invitations are sent.
Would setting minPlayerToStart to 1 and only include oneself in the invite list would suffice in creating an SFSGame with one player, which then he can invite other user in?
No, this is not the way things work.
If you want to start a game for 3 players you must specify how many players there will be in the Room. The game will not start until the number of players will be reached.

cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
aaulia
Posts: 31
Joined: 28 May 2011, 18:50

Re: SFSGame and Room password.

Post by aaulia »

Lapo wrote: Also you don't need to invite the creator itself. He's automatically joined in the Room as player #1.
Hmm about this, I've tried creating a SFSGame room with minPlayerToStart = 2. Logically if I (the owner/creator) were already included, that means I only need to supply one other user id for the invite list. But what happen is, the server throw exception saying the invite list that I sent along is not enough to cover the required 2 minPlayerToStart. So I included myself in the invite list, and it works, which is weird to say the least (this is not production code, just some prototyping). Which is why I assume I also need to invite myself.
That's what is already happening.
First the Room is created and the owner is joined. Then invitations are sent.
Hmm, yeah I think the miss match here is that we are trying to match the Client UI flow with the SFS flow. What we would like is actually to have a room first, and then the owner can pick who to invite from inside that room (and other people who are inside, already agreed to join, can also invite others). I guess I need to think/talk about this again.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFSGame and Room password.

Post by Lapo »

Which server version are you using please?
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
aaulia
Posts: 31
Joined: 28 May 2011, 18:50

Re: SFSGame and Room password.

Post by aaulia »

Code: Select all

 _____ _____ _____    ___ __ __
|   __|   __|   __|  |_  |  |  |
|__   |   __|__   |  |  _|-   -|
|_____|__|  |_____|  |___|__|__|
 _____ _____ _____ ____  __ __
| __  |   __|  _  |    \|  |  |
|    -|   __|     |  |  |_   _|
|__|__|_____|__|__|____/  |_|
[ 2.8.2 ]

17:13:16,302 INFO  [main] v2.SmartFoxServer     - SmartFoxServer 2X (2.8.2) READY!
Here, is the exception

Code: Select all

17:29:58,111 WARN  [com.smartfoxserver.v2.controllers.SystemController-1] contro
llers.SystemController     - com.smartfoxserver.v2.exceptions.SFSCreateGameExcep
tion: Invited players (size = 1) are not enough to start the game (min = 2). Add
itionally no searchable rooms were provided
        com.smartfoxserver.v2.api.SFSGameApi.validateSFSGameSettings(SFSGameApi.
java:341)
        com.smartfoxserver.v2.api.SFSGameApi.createGame(SFSGameApi.java:95)
        com.smartfoxserver.v2.api.SFSGameApi.createGame(SFSGameApi.java:83)
        com.smartfoxserver.v2.controllers.system.game.CreateSFSGame.execute(Crea
teSFSGame.java:141)
        com.smartfoxserver.v2.controllers.SystemController.processRequest(System
Controller.java:131)
        com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractC
ontroller.java:96)
        java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        java.lang.Thread.run(Unknown Source)
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFSGame and Room password.

Post by Lapo »

Thanks,
I've checked out bug database and found an entry for this case. I know it's already fixed but we're waiting the "green light" for a couple of other bugs that were fixed. Once those are ready we'll release the update.

There is a workaround that one can use, at least temporarily to avoid the problem.
Something like this:

Code: Select all

settings.playerMatchExpression = new MatchExpression("BestScore", NumberMatch.GREATER_THAN, 100)
settings.searchableRooms = ["default"]
You provide a group name where to search more users and a MatchExpression. The only thing is that "BestScore" is not a real UserVariable used for players.

This way the system will accept the discrepancy in number, attempt to search users although won't find anybody matching a non-existing UserVariable.

Yeah I know, not pretty. But it allows to keep developing and testing.
As I said we're releasing an update soon, so it can be used for the time being and removed later.

cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply