Forum Multiplayer Refreshing the lobby

Discussion and help relating to the PlayerIO Multiplayer API.

Refreshing the lobby

Postby Sidog » February 4th, 2010, 12:36 pm

Hi ,

I'm not sure if the problem is just at my end but I've noticed the following with the lobby.

When user A joins the game and creates a room that room only becomes visible to user B if he connects to the server after that game has been created. If user A and B are both connected and user A creates a game then the game won't be visible to user B.

I've noticed there's a function in the lobby.as file called refresh is the best way to get around this to just have users call that function at given intervals ? Is there any plans to have some kind of event for the roomsList changing to be broadcast to all users that are connected to the server and not in a Room (so waiting in the lobby)

Cheers ,

Sidog
Sidog
 
Posts: 5
Joined: January 23rd, 2010, 1:31 pm

Re: Refreshing the lobby

Postby Oliver » February 4th, 2010, 2:52 pm

Hi,

Yes -- the idea is that you call list rooms with the correct criteria once in a while.

We made a deliberate decision not to send out live updates as rooms are being created/closed/entered/left, since we want games built on top of player.io to "just scale", and potentially sending an update for each room create/close/enter/leave is a lot of traffic.

The list rooms method will never return more than 1000 rooms, so when you reach that point you have to use the limit and search criteria arguments to get the right ones.

http://playerio.com/documentation/refer ... #listRooms for more info about the arguments.

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Refreshing the lobby

Postby Benjaminsen » February 4th, 2010, 3:01 pm

In the case where you need live lobby environment you also often want to have more than simple list of rooms. Thus we made sure that you are able to use the whole Multiplayer Infrastructure for such a sub service.

Simply make a separate DLL to keep track of your lobby and connect to that as well from the client.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Refreshing the lobby

Postby Sidog » February 6th, 2010, 5:35 pm

cool , thanks for the reply
Sidog
 
Posts: 5
Joined: January 23rd, 2010, 1:31 pm

Re: Refreshing the lobby

Postby Swoopjockey » February 9th, 2010, 2:33 am

Thank you for addressing this question, it was something I was interested in as well.

Adding a simple "Refresh List" button and attaching the refresh function to it did the trick.

I have a few more questions, you mentioned using the search criteria property to filter results. In the documentation, this is listed as an Object, and says "to be implemented". Does this mean it is not working yet? Could you please explain how to use this to filter results?

Also, how do I set the max connections to each game? I only want four players per table at a time.

Is there a way to setup private games with a password?

Is there a way to "share" a link to the gameroom? Basically, I want players to be able to invite their friends to join them in a room via a "hey, come play with me" sort of link.

Thanks

EDIT:

OK, I read through the provided documentation, and was able to set a "limit" of 4 players on the server code. But I'm still interested in game list "sorting" and "sharing" as well as private games.
Swoopjockey
 
Posts: 21
Joined: February 5th, 2010, 2:17 pm

Re: Refreshing the lobby

Postby Oliver » February 9th, 2010, 12:25 pm

I have a few more questions, you mentioned using the search criteria property to filter results. In the documentation, this is listed as an Object, and says "to be implemented". Does this mean it is not working yet? Could you please explain how to use this to filter results?


Woops, that's an oversigt in the documentation -- it should work just fine. What you need to do however is set the search settings under your multiplayer game to the properties of the RoomData you wish to be searchable:

temp.gif
temp.gif (8.36 KiB) Viewed 25620 times


For instance, let's say you want to list rooms based on "map".

First, you'll pass in the following as roomdata when creating the room:
Code: Select all
...createRoom("anyroomid","myservertype",true,{map:'air-fight'}, ...)

(you can also set/change the room data from the serverside code, for instance if the room changes map or similar)

Then, you'll need to write "map" in one of the search column fields (remember to save):
temp2.gif
temp2.gif (2.68 KiB) Viewed 25620 times


And then you can list rooms that are in the maps you want:
Code: Select all
...listRooms("myservertype", {map:'air-fight', 10, 0, ...)


Also, how do I set the max connections to each game? I only want four players per table at a time.

There are multiple ways to do this.

A simple way is to simply toggle the Visible property in your serverside code. Whenever a room is not visible, it doesn't show up when calling listRooms(...). If nobody sees it, nobody joins it....

You can also extend on that by disallowing joins by overriding the AllowUserJoin method in your serverside code:

Code: Select all
   public override bool AllowUserJoin(BasePlayer player) {
      if(PlayerCount < 4) {
         return true;
      } else {
         return false;
      }
   }


Is there a way to setup private games with a password?

Why yes there is: Build it yourself :-). For instance, give the room a password by in the room data (either via createRoom(...) or from the serverside).

Code: Select all
...createRoom("myroom","myservertype",true,{password:'123test'}, ...)


Then when joining the room, send in the password in the joinData argument of joinRoom:

Code: Select all
joinRoom("myroom", {password:'123test'}, ...)


And then use the AllowUserJoin method to determine if you want to let the user play:
Code: Select all
   public override bool AllowUserJoin(BasePlayer player) {
         if( RoomData.ContainsKey("password") ){
            var password = RoomData["password"];

            // room has password, check the users supplied password
            if( player.JoinData.ContainsKey("password") ){
               return password == player.JoinData["password"]; // true if they're the sa
            }else{
               return false; // user did not supply password.
            }
         }else{
            // rooms with no passwords can always be joined.
            return true;
         }
      }



Is there a way to "share" a link to the gameroom? Basically, I want players to be able to invite their friends to join them in a room via a "hey, come play with me" sort of link.

Again, sure: Just figure out a way to pass a roomid around.

For instance, if you create a room called "olivers game"
Code: Select all
...createRoom("olivers game","myservertype",true,{'}, ...)


Then you can tell your player to share the name with another player over any medium (msn, skype, e-mail....). Then you have to provide an input field where players can enter a room-id to join that game.

If you're building a game for your own website, you can even make the room-ids as part of the urls and simply tell players to share the urls among themselves.

It's all up to you and your imagination. :-)
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am

Re: Refreshing the lobby

Postby Swoopjockey » February 11th, 2010, 6:40 am

Thank you Oliver for providing such a detailed response.

I was able to implement the search function fairly easily. The only problem is that I want players to be able to search by game name. It seems that the sorting function only returns exact strings, not inclusive strings.

What I means is I can't search for games that include "Fun" in the title. For example, "Bob's Fun Game" won't show up. Only games named exactly "Fun" will.

I haven't had time to implement the password or sharing functions, but with your examples I can hopefully manage that on my own.

The only reason I bring this up is that the purpose of player.io seems to be for developers to spend more time on game code and less on server functionality. I understand that you want to leave things up to the creator's imagination, but these options seem basic enough that they should probably be included as sample functions. Or even provide the details you gave me in the documentation.

Again, thank you for providing such detailed feedback. I have really enjoyed using the API so far.
Swoopjockey
 
Posts: 21
Joined: February 5th, 2010, 2:17 pm

Re: Refreshing the lobby

Postby Oliver » February 12th, 2010, 10:49 am

Thank you Oliver for providing such a detailed response.


No problem, i like it :-)

I was able to implement the search function fairly easily. The only problem is that I want players to be able to search by game name. It seems that the sorting function only returns exact strings, not inclusive strings.

What I means is I can't search for games that include "Fun" in the title. For example, "Bob's Fun Game" won't show up. Only games named exactly "Fun" will.


Yes, search criteria are currently only exact matches on strings.
You can do the includes check yourself, by listing all games and doing the check in the client; this sounds bad, but unless your game gets massively popular, it won't really be an issue.

Now, you'll probably say that it's a stupid way to achieve the desired result -- and I agree with you -- but, the thing is that our backend storage for room data is optimized to handle exactly the kinds of queries that we allow. That is; we've built it in such a way that we can guarantee that the interface we expose will scale; which is a very important point for us. If we were to add InStr searches to that interface, we'd have to go back and ensure that our room-storage would scale even if every room listing we got was an instr search and even if every game had a million active rooms.

I'm not saying we won't ever add the feature in the future. Our approach has always been to start out with a rock solid foundation, and then build on top of that according to feedback and feature request.

Our, put more bluntly, if enough people asks for it, we'll build it.

The only reason I bring this up is that the purpose of player.io seems to be for developers to spend more time on game code and less on server functionality.


That's pretty close to what we're saying internally: "Provide tools and services that handle the hard and tedious issues, so the developer can spend more time and focus on the thing that matters most; gameplay!"

Again, thank you for providing such detailed feedback. I have really enjoyed using the API so far.

It's what we're here for! Awesome that you like the API!

- Oliver
User avatar
Oliver
.IO
 
Posts: 1159
Joined: January 12th, 2010, 8:29 am


Return to Multiplayer



cron