Author Topic: Lobby Multiple Simultaneous Logins  (Read 6370 times)

kbar

  • Jr. Member
  • **
  • Posts: 91
  • Karma: 3
    • View Profile
    • GameLogicDesign
Lobby Multiple Simultaneous Logins
« on: November 08, 2010, 07:06:16 AM »
I need to be able to let users log in, and stay logged in, from multiple devices.

A user could log in from their iPhone and be connected all the time to a Lobby. This could be displaying game statistics, who's online, friends lists, let them message people etc...  

The same user then logs on from their PC, Xbox or PS3 and can also play a game. When a message is sent it fills out the deviceID with their ID. The user can also fill out an optional sendToDeviceID which when set will only send the message to the user on that particular device, otherwise it will send to all devices. (like the Rooms Plugin, and the Rooms plugin should also be updated to include the deviceID).

It should also allow the user to log in multiple times from the same device. This would allow the user to have two games (or applications) running on the same computer and allow them to talk to each other.


Example uses
- Play a game on a Xbox360 and also have an iPhone app that enhances the game (extra buttons for special commands).
- Play a game on an Xbox360 and use the iPhone/iPad as a controller (buttons on the screen, motion controlled).
- Let the user monitor some processes that are running on Multiple computers from their iPhone. They are logged into 10 computers with the same account name, with a different device ID for each. And also logged into their iPhone for monitoring all the computers and their progress.

//=====================================

Client_Login

// Input parameters
RakNet::RakString deviceID; //If set then is used for Multiple Logins. Specify a device (or application) name "iPhone", "OSX", "PC", "XBox", "My Game A on Computer A", "My Game B also on Computer A", "Application A" etc...


The deviceID should be added to all structs that also specify the userName.
Its up to the integrator of RakNet to decide to use and check this if they actually want to allow multiple devices. If its not set then only a single logon is possible (or perhaps when its not set then it is the main user account).



How I might implement this myself
--------------------------------------------------
If the above is not possible then I will do it by prefixing the user name with an ID.

So when the user Logs in they login with a username like  "000000000_John", "000000001_John","000000002_John" etc...

I would then need to figure out a way to manage the ID's, reuse them etc... And also automatically add and remove friends when user logs in and out.  


« Last Edit: November 08, 2010, 08:27:58 AM by kbar »

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: Lobby Multiple Simultaneous Logins
« Reply #1 on: November 09, 2010, 09:55:14 AM »
Currently Lobby2Server::OnLogin will log you out if you log in with the same IP address, guid, or username as someone already logged in. This could be modified to be optional, and instead have a list of systemAddress structures per user, so that you can be logged in multiple times as the same user.

You could set which devices you are on with Client_SetPresence. The only problem I forsee is contention. Currently there is only one presence structure and it is set by the client. So if you logged in on two devices at the same time the 2nd Client_SetPresence would overwrite the first. One to fix this is to have the presence string instead be an array, with a corresponding boolean array saying whether or not to update that index. Another way would be to reject the update if it is overwriting more recent data, and send the failure back to the user for the user to figure out what to do. Which would work for you?

I would also need to update the RoomsPlugin to support multiple IP addresses per user.

Also, are you a licensed user?

OvermindDL1

  • Anti-Spam Moderator
  • Hero Member
  • ****
  • Posts: 855
  • Karma: 40
  • Programmer
    • View Profile
    • OvermindDL1's Site
Re: Lobby Multiple Simultaneous Logins
« Reply #2 on: November 10, 2010, 08:05:34 AM »
You might take a look at how the XMPP protocol standard handles it.  Usernames first of all are of the form of "username@server/resource", thus if I were logged it from my phone it might read "OvermindDL1@myserver.com/OverPhone" (since my phone's name is OverPhone), and from my home computer being something like "OvermindDL1@myserver.com/home" or so, as long as the resource is different.  If an existing resource is logged in it either logs out the oldest (old disconnected session) or so, do not recall for sure.  The standard has gone through many revisions in the past ten years so it seems to be quite well solved.

kbar

  • Jr. Member
  • **
  • Posts: 91
  • Karma: 3
    • View Profile
    • GameLogicDesign
Re: Lobby Multiple Simultaneous Logins
« Reply #3 on: November 11, 2010, 04:42:13 AM »
Which would work for you?

Having one presence data is correct. Since it is the same user on all machines, all the users friends would only see a single person as online, with a single status message. If one machine changes the information then it sends a notification to all the other machines that you are logged onto with the new presence data.

When you mentioned using the presence string are you referring to the "statusString" or maybe the "titleNameOrID" in the Lobby2Presence structure? And making one of these an array?

As for which would work for me I am not sure since I think there should only be one presence data. Perhaps you could explain a bit more about how you would use the "presence string".

Also, are you a licensed user?

No I am not a licensed user. I am developing a prototype application which is using RakNet. Once I have it feature complete I will put it into testing and then I would look at contacting you for a proper license if required (well I would contact you anyway since RakNet is helping out a great deal).

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: Lobby Multiple Simultaneous Logins
« Reply #4 on: November 11, 2010, 10:39:56 AM »
Yes, I mean statusString. If you changed your status on two systems at the same time, only the second one processed would take place. That is why I proposed either an array, only changing one element in the array from one system, or to return an error to the user so you can basically merge the fields by hand. Or come to think of it, if you made a custom version of the functor you could have the status string actually be a command, such as "ADD IPHONE" and parse that on the server, modifying whatever value was there now. That is actually a better solution because what you are doing is very specific.

I'll go and see about supporting multiple IP addresses now. Look to this post for an update soon.

Rak'kar

  • Administrator
  • Hero Member
  • *****
  • Posts: 6895
  • Karma: 291
    • View Profile
    • RakNet
Re: Lobby Multiple Simultaneous Logins
« Reply #5 on: November 11, 2010, 06:22:52 PM »
Try this out. Let me know if you encounter bugs
http://raknet.svn.sourceforge.net/viewvc/raknet/branches/RakNet4/

You have to set in Client_Login to allow multiple logins for that user.