I am building a buddy list with display of buddies with the following states: Offline, Online and Ingame.
In case a buddy is Ingame, I can join his room and play with him.
Is there a way to retrieve if a Buddy is a player (in game), if I am in a Lobby and the Buddy is in a game room?
Buddy interface allows me only to see offline and online states.
I have a workaround to get an ingame state via IUserManager:
var user:User = smartfox.userManager.getUserByName(buddy.name);
user.isPlayer provides information that this user is a player (ingame).
BUT there is another problem - you cannot retrieve a user with IUserManager which is not in your room (lobby), therefore resulting that user is null.
There must be some solution other than fetching the data from the server.
Currently I am using temporary solution: if a buddy is online and not in lobby (user==null), therefore user must be ingame.
I have also found an error in my implementation because of a strange fact:
If an User object is retrieved via userManager.getUserName() with a client who is in a lobby (non player room), it will have a property isPlayer False (but actually that user is a player in a game room)!?
Effectively resulting that the inGame variable will be false (but online).
Here is the part of my code (used later as a list dataprovider):
Code: Select all
_userId = buddy.id;
_online = buddy.isOnline;
var user:User = smartfoxserver.userManager.getUserByName(buddy.name);
if (user!= null) {
_inGame = user.isPlayer;
} else {
if (_online) {
//user manager didnt found user in lobby room -> must be ingame
_inGame = true;
} else {
_inGame = false;
}
}Many thanks!
Best regards,
Boris