My Community
October 20, 2014, 07:29:50 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: 6/29/2011 RakNet 4.022 released.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Return GUIDs in Lobby2Presence  (Read 1566 times)
kbar
Jr. Member
**

Karma: 3
Posts: 91


View Profile WWW
« on: April 06, 2011, 06:28:39 AM »

This is something I have asked for previously. I have written my own p2p raknet plugin that maintains p2p connections to all your friends that are logged in to the lobby. It uses some special code that I have added to the Lobby2 that serializes the GUID of the user in the Lobb2Presence data.

It might not be 100% correct RakNet code but it works and helps alot. It doesn't yet take into account multiple user logins with the same account name.

It would be great to see a proper RakNet way of serializing guids from the Lobby.

Note: This has nothing to do with the Rooms plugin.

Code:
void Lobby2Server::GetUserOnlineStatus(UsernameAndOnlineStatus &userInfo) const
{
unsigned int idx = GetUserIndexByUsername(userInfo.handle);
if (idx!=-1)
{
User *pUser = users[idx];
userInfo.isOnline=true;
userInfo.presence= pUser->presence;0);
userInfo.presence.guid = pUser->guids.Get(0);
}
else
{
userInfo.isOnline=false;
userInfo.presence.status=Lobby2Presence::NOT_ONLINE;
userInfo.presence.isVisible=false;
}
}


Code:
void Lobby2Server::GetPresence(RakNet::Lobby2Presence &presence, RakNet::RakString userHandle)
{
unsigned int userIndex = GetUserIndexByUsername(userHandle);
if (userIndex!=-1)
{
User *pUser = users[userIndex];
presence = pUser->presence;
presence.guid = pUser->guids.Get(0);
}
else
{
presence.status=Lobby2Presence::NOT_ONLINE;
}
}

Code:
Lobby2Presence::Lobby2Presence(const Lobby2Presence& input) {
status=input.status;
isVisible=input.isVisible;
titleNameOrID=input.titleNameOrID;
#if defined(_XBOX) || defined(X360)
                                                                   
#endif
statusString=input.statusString;
guid=input.guid;
}
Lobby2Presence& Lobby2Presence::operator = ( const Lobby2Presence& input )
{
status=input.status;
isVisible=input.isVisible;
titleNameOrID=input.titleNameOrID;
#if defined(_XBOX) || defined(X360)
                                                                   
#endif
statusString=input.statusString;
guid=input.guid;
return *this;
}

Code:
struct Lobby2Presence
{
                .....

RakNet::RakNetGUID guid;
};
Report to moderator   Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.17 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!