Forum BigDB Transitioning from SmartFox, buddy list?

Discussion and help relating to the PlayerIO database solution, BigDB.

Transitioning from SmartFox, buddy list?

Postby markloika » July 8th, 2010, 9:53 am

I'm transitioning from SmartFoxServer PRO, and I am wondering how to have a buddy list in a similar fashion to how SFS does it.

How SFS does it:

A user has a buddy list which contains all of the data that each buddy on the list has set as their buddy variables. A buddy variable might be a status message, or a nickname, or anything. If user1 is on user2's buddy list, and user1 changes his status buddy variable, user2 receives an event (if user2 is online) saying user1's buddy variables changed along with the updated buddy variables. Buddy variables can persist offline, so if user1 changes his status and user2 is offline, user2 will receive user1's new status the next time user2 logs in and loads the buddy list.

I need this functionality for my game, so I'm wondering how to achieve this functionality using Player.IO. Does Player.IO have any built-in buddy list features? If there are none, I was thinking of creating this functionality by doing the following:

1. Have a DatabaseArray that lists the names of friends, stored in a user's PlayerObject.
2. Changing one's buddy variables mean sending a message to the server which would call a function, which would then get the list of friends from the PlayerObject, and then it would send a message to all of the friends (who are online)
3. That function would also save one's buddy variables in the database, and when a user logs in, all of the buddy variables for their friends are retrieved and sent to the user

(I'm new to Player.IO, so please bear with me)

It seems like the above logic would be easy enough to implement, but after looking for a short while I wasn't able to find a way to 'get' a user in order to send them a message. In the GotMessage function there is a Player variable, and then a message can be sent to that player by calling player.send(), but how do I retrieve other player variables? If I got the list of names of friends from the database, how would I send all of those friends a message?

All help is appreciated,
Mark
markloika
 
Posts: 76
Joined: July 8th, 2010, 3:46 am

Re: Transitioning from SmartFox, buddy list?

Postby fox1980 » July 8th, 2010, 4:07 pm

PlayerIO doesn't have a builtin buddy list function, you'll have to implement it yourself. Tough you're almost correct on your line of tough, there's one little thing you must have in mind:

2. Changing one's buddy variables mean sending a message to the server which would call a function, which would then get the list of friends from the PlayerObject, and then it would send a message to all of the friends (who are online)


With Playerio you can't send a message to just anyone at will, even if they are online. You can only send messages to people in the same room, so people on other rooms would only see the update when they logged in again. You can work around that limitation by polling BigDB each x seconds or minutes to check if the variables have been changed, but i would advise against that. It would be a waste of bandwith, especially when you have lots of users online.

To send a message to each online friend in the buddy list in the same room you would iterate the Players collection and check the userid, something like this (pseudo-code):

Code: Select all

for each x as Player in Players
{

   if (x.connectuserid==connectuserid_you_want_to_check)
   {
       x.send("UPDATE",whatever you want to send);
   }
}

fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Transitioning from SmartFox, buddy list?

Postby markloika » July 8th, 2010, 6:54 pm

Thanks for the reply.

I think perhaps I wasn't clear with the logic about how to do the buddy list. The server would be getting the list of friends from the user's player object, then the server would send a message to each player who is online. I'm hoping when you said the server can only send messages to people in the same room you meant that from the client a user can only send messages to people in the same room, because if you meant from the server side that wouldn't make any sense. I would assume that the server is all-seeing, and can manage all online users and all rooms.

I'm working on this now, so I guess I'll see if it works.
markloika
 
Posts: 76
Joined: July 8th, 2010, 3:46 am

Re: Transitioning from SmartFox, buddy list?

Postby fox1980 » July 8th, 2010, 7:23 pm

No, i truly meant the server can only send messages to people on the same room. Your gamecode.dll will be instanced for each room in your game, and is not aware of how many more instances there are. The server is not all seeing nor does it handle all online users, only the ones connected to that instance.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Transitioning from SmartFox, buddy list?

Postby markloika » July 8th, 2010, 8:29 pm

Ah, ok. With SmartFox you have the choice of having the server-side logic instanced per room, or you can have one instance that manages all rooms (or even both). Which means that the server can send anything to any room or any user, so a user in room A could send a private message to a user in room B.

There is no possible way for a user in one room to communicate with a user in another room? In my game using SmartFox, a user can always access his list of friends, and then he can invite a friend to the game he's currently in, chat with that friend, etc, all regardless of what room he or his friend is in. The ability for one friend to invite another friend to a game is pretty important, is there no way to achieve this with Player.IO?

Can a user be connected to multiple rooms? With SmartFox, a user can be connected to any number of rooms, and there are different types of rooms. One room type is limbo, which is a special room designed to handle tens of thousands of users because a user cannot broadcast information to all users in that room, and the room isn't notified about events such as a user entering or leaving, but the user can still interact with the server and send private messages to other users who may be in the same limbo room or elsewhere. A limbo room is what's used for a lobby room that all players automatically connect to when they load the game.

I read somewhere in the documentation that a room is limited to 45 players. Are there different types of rooms? Is there some equivalent to a SmartFox limbo room that every player playing the game could be in?
markloika
 
Posts: 76
Joined: July 8th, 2010, 3:46 am

Re: Transitioning from SmartFox, buddy list?

Postby fox1980 » July 9th, 2010, 12:16 pm

There is no possible way for a user in one room to communicate with a user in another room? In my game using SmartFox, a user can always access his list of friends, and then he can invite a friend to the game he's currently in, chat with that friend, etc, all regardless of what room he or his friend is in. The ability for one friend to invite another friend to a game is pretty important, is there no way to achieve this with Player.IO?


There is no way to send messages from one room to another through the API. The only way i can think of is writing the message in a BigDB table, then having users poll that table at regular intervals, or on certain events and query that table to check if they have new messages. After they read the message you can probably just delete it depending on what you're trying to do. You could invite players to your buddy list like that, tough it wouldn't be in real time it could come quite close.

Can a user be connected to multiple rooms? With SmartFox, a user can be connected to any number of rooms, and there are different types of rooms. One room type is limbo, which is a special room designed to handle tens of thousands of users because a user cannot broadcast information to all users in that room, and the room isn't notified about events such as a user entering or leaving, but the user can still interact with the server and send private messages to other users who may be in the same limbo room or elsewhere. A limbo room is what's used for a lobby room that all players automatically connect to when they load the game.


Even tough i don't recall reading anything like that from the documentation, from my experience i could connect to several rooms at the same time, at least it showed so in the development server, tough i could only send messages to the last room i connected. All rooms have a 45 user limit tough, so i don't think it would help that much. Again you can work around it by creating a limbo table in BigDB and maintain a list of connected users.

I read somewhere in the documentation that a room is limited to 45 players. Are there different types of rooms? Is there some equivalent to a SmartFox limbo room that every player playing the game could be in?


There is only 1 type of room as far as i'm aware.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Transitioning from SmartFox, buddy list?

Postby Benjaminsen » July 9th, 2010, 1:19 pm

First off, great question! More than just answer your question I would like to give a little background about our systems and why everything is as it is. To do this I made the below FAQ based on the questions I would have if I saw the system from outside.

Hey! Why can't I send messages to all players connected to my game?
When you run a game using Player.IO your game will be run on more than one server. Sending messages between servers are none trivial and thus we don't offer a solution for it for now.

Thats stupid! Why are you running my game on more than one server?
One of our primary goals with Player.IO is scalability, not to a few thousands, but to millions of concurrent online players. To reach this goal we had to build a model where room instances for one game can run on more than one server or even in more than one data center.

But SmartFox can do it!
Smartfox have the same limitations as us, the only difference is that they allow more people to be in a single room. If you never count on scaling your game to more than a few thousand users SmartFox might be an easier choice for now.

For now? What are you hinting at?
What you are asking for is essentially a global presence system. IE a system where you for any user can tell if they are connected and what state they are in, similar to how your buddy list on Skype or MSN works. As it should be clear by now, implementing such a system is none trivial, but still a feature lots of developers want.

The good thing about none trivial systems that everybody wants, is that it's the kind of systems we like implementing as APIs at Player.IO. Thus a global presence system is already in the pipeline. The bad news, is that we have a lot of other systems to create first so it will likely be several months before the system is ready.

So what should I do until then?
If you can't wait, it's quite possible to create your own presence system using Multiplayer and BigDB. Even better, I have decided to make it as a small example until we get a more generic solution in place. ETA is sometime mid next week.

Lastly, I want to point out that it is possible to be connected to more than one room at the same time.

/Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Transitioning from SmartFox, buddy list?

Postby fox1980 » July 9th, 2010, 2:37 pm

Thanks for shedding some light into this Chris. I also still have some doubts on particular things that have to do how the system works, but i'm waiting till i actually have to use them before i bring them forward.

You said we can connect to several rooms at the same time, i tested it before and i know it works, but what's the real advantage in that ? Also, i found out when we disconnect the client we automatically leave all rooms at the same time, how to make the client leave only one specific room ?
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Transitioning from SmartFox, buddy list?

Postby Benjaminsen » July 9th, 2010, 2:41 pm

fox1980 wrote:Thanks for shedding some light into this Chris. I also still have some doubts on particular things that have to do how the system works, but i'm waiting till i actually have to use them before i bring them forward.

You said we can connect to several rooms at the same time, i tested it before and i know it works, but what's the real advantage in that ? Also, i found out when we disconnect the client we automatically leave all rooms at the same time, how to make the client leave only one specific room ?


Being connected to several rooms allow you to do things like separating actual gameplay and a chat. Thus you could be playing TicTacToe with one person while chatting to 45 others.

Disconnecting from the client should not disconnect you from all rooms you are connected to. If you can make an example that have that behavior I would really like to see it.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Transitioning from SmartFox, buddy list?

Postby fox1980 » July 9th, 2010, 3:32 pm

I'll try and get a simple example that replicates what i mean. Even if i'm proved wrong, if disconnecting the client doesn't disconnect from all rooms, what was it supposed to do ? Disconnect from the last room entered ? I reviewed everything relative to this on the documentation and i found out no way of disconnecting from only a specific room.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Transitioning from SmartFox, buddy list?

Postby Benjaminsen » July 9th, 2010, 3:37 pm

fox1980 wrote:I'll try and get a simple example that replicates what i mean. Even if i'm proved wrong, if disconnecting the client doesn't disconnect from all rooms, what was it supposed to do ? Disconnect from the last room entered ? I reviewed everything relative to this on the documentation and i found out no way of disconnecting from only a specific room.


Disconnects are done from the connection object. You get a unique connection object every time you connect to a room. Storing references to several unique connection objects allow you to be in multiple rooms.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Transitioning from SmartFox, buddy list?

Postby fox1980 » July 9th, 2010, 3:49 pm

Ok, that makes sense. No need to setup an example then, what i was doing was issuing the joinroom command several times on the same connection object. It doesn't replace the current connection tough, it just joins a new room rendering it impossible to send messages to the previous rooms while still being connected to them, and it also explain why disconecting would quit all rooms at once.
fox1980
 
Posts: 206
Joined: April 1st, 2010, 10:39 pm

Re: Transitioning from SmartFox, buddy list?

Postby markloika » July 10th, 2010, 6:17 am

Thanks for the insight Chris. I made my own presence system today, I posted the code in the multi-login thread in the Multiplayer category.
markloika
 
Posts: 76
Joined: July 8th, 2010, 3:46 am

Re: Transitioning from SmartFox, buddy list?

Postby Benjaminsen » July 10th, 2010, 8:31 am

markloika wrote:Thanks for the insight Chris. I made my own presence system today, I posted the code in the multi-login thread in the Multiplayer category.


Just saw your post in the Multiplayer Category. Looks like great work! I will still create a presence system myself as a more official example, but I will redirect users to your solution until then.

/Chris
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Transitioning from SmartFox, buddy list?

Postby markloika » July 10th, 2010, 9:20 am

Benjaminsen wrote:
markloika wrote:Thanks for the insight Chris. I made my own presence system today, I posted the code in the multi-login thread in the Multiplayer category.


Just saw your post in the Multiplayer Category. Looks like great work! I will still create a presence system myself as a more official example, but I will redirect users to your solution until then.

/Chris


Thanks! I look forward to seeing your implementation.

Mark
markloika
 
Posts: 76
Joined: July 8th, 2010, 3:46 am

Re: Transitioning from SmartFox, buddy list?

Postby Benjaminsen » July 12th, 2010, 5:56 pm

As promised here is a Player.IO based presence server.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Transitioning from SmartFox, buddy list?

Postby adolfainsley8 » April 18th, 2016, 11:23 am

I will still create a presence system myself as a more official example, but I will redirect users to your solution until then????


== Chess ==
adolfainsley8
 
Posts: 1
Joined: April 18th, 2016, 11:22 am


Return to BigDB



cron