Getting knowledge about runtime created game rooms

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

Moderators: Lapo, Bax

braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Getting knowledge about runtime created game rooms

Postby braza » 26 Nov 2014, 18:44

Hi! I got back to my project after a delay.
This time I want to get to the bottom of an issue that bothered me for a long time.

Lets say I have two users.
1. I can see rooms created by users only if they were both logged in by that moment. How can I request list of rooms that were there before I log in?
2. If clien that gets notified about the rooms tries to see how many users are there it wont count the creator in my case. I see 0/2 instead on that client. Oreator sees this room as 1/2.

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

Re: Getting knowledge about runtime created game rooms

Postby Lapo » 27 Nov 2014, 09:59

Hello,
braza wrote:Lets say I have two users.
1. I can see rooms created by users only if they were both logged in by that moment. How can I request list of rooms that were there before I log in?

You can't :)
First you need to login, with or without credentials is up to the developer.
Then you can talk with the server API. No login, no joy :)

The list of rooms is actually sent back in the login response.

2. If clien that gets notified about the rooms tries to see how many users are there it wont count the creator in my case. I see 0/2 instead on that client. Oreator sees this room as 1/2.

This I don't understand. The number of players / spectators is any Rooms reflects exactly the number of people inside that Room. There are no exceptions.

Can you better explain what is the problem you see?

cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Re: Getting knowledge about runtime created game rooms

Postby braza » 29 Nov 2014, 22:56

Lapo wrote:Hello,
braza wrote:Lets say I have two users.
1. I can see rooms created by users only if they were both logged in by that moment. How can I request list of rooms that were there before I log in?

You can't :)
First you need to login, with or without credentials is up to the developer.
Then you can talk with the server API. No login, no joy :)

The list of rooms is actually sent back in the login response.

2. If clien that gets notified about the rooms tries to see how many users are there it wont count the creator in my case. I see 0/2 instead on that client. Oreator sees this room as 1/2.

This I don't understand. The number of players / spectators is any Rooms reflects exactly the number of people inside that Room. There are no exceptions.

Can you better explain what is the problem you see?

cheers


1. That's the info I needed! Rooms created before login arrive in the LoginResponse! Thanks! I'll try that.
2. http://screenpresso.com/=TKVXf
You see 1/2 and 0/2?

Code beghind is the same on both clients of course:

Code: Select all

   public void OnScrollPanelItemVirtualize( object backingListItem )
   {
      room = (Room) backingListItem;
      
      GameName.Text = room.Name;
      UserCount.Text = room.UserCount + "/" + room.MaxUsers;
      Debug.Log("[GUI]Room with " + room.UserCount + " users in it added to panel");
   }
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Getting knowledge about runtime created game rooms

Postby Lapo » 01 Dec 2014, 13:47

As regards point #2, are both users inside the Room? One inside and one outside?
Outside of a specific Room you will need to listen to the USER_COUNT_CHANGE event. When you have joined the Room you should also listen for USER_ENTER_ROOM and USER_EXIT_ROOM to get updated about changes in the Room.

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Re: Getting knowledge about runtime created game rooms

Postby braza » 07 Dec 2014, 02:31

Lapo wrote:As regards point #2, are both users inside the Room? One inside and one outside?
Outside of a specific Room you will need to listen to the USER_COUNT_CHANGE event. When you have joined the Room you should also listen for USER_ENTER_ROOM and USER_EXIT_ROOM to get updated about changes in the Room.

thanks

One is in and one is out, right. Thanks for pointing out events to listen. Great support!
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Re: Getting knowledge about runtime created game rooms

Postby braza » 17 Jan 2015, 17:16

Hi again!
No I actually decided to fix that and wondering how am I supposed to find that room info there in the response... I do ot see it mentioned here http://docs2x.smartfoxserver.com/api-do ... 35530d.htm
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Getting knowledge about runtime created game rooms

Postby Lapo » 19 Jan 2015, 09:57

Sorry, I am not following.
Can you explain what you have fixed exactly?

Also, in particular,
how am I supposed to find that room info there in the response

What response?

thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Re: Getting knowledge about runtime created game rooms

Postby braza » 20 Jan 2015, 00:15

Lapo wrote:The list of rooms is actually sent back in the login response.


I want to extract the data you mentioned. The rooms that were dynamically created before I logged in.
So I look into login response docs http://docs2x.smartfoxserver.com/api-do ... 35530d.htm and do not see how am I supposed to get it...
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Getting knowledge about runtime created game rooms

Postby Lapo » 20 Jan 2015, 09:37

The list of Rooms is not passed directly in the event, but you can obtain it at any time from the SmartFox.roomList property, after having logged in.

If you're working in Java there's an equivalent method called getRoomList().

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Re: Getting knowledge about runtime created game rooms

Postby braza » 20 Jan 2015, 12:19

Lapo wrote:The list of Rooms is not passed directly in the event, but you can obtain it at any time from the SmartFox.roomList property, after having logged in.

If you're working in Java there's an equivalent method called getRoomList().

Cheers


aaaaah, I see! Thanks!

Return to “SFS2X Questions”

Who is online

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