0

I am using photon chat plugin in a unity3d multiplayer game. I have added some friends and can send them private message. I want to show if that friend is online or not.

I can use on status update callback, but it will show only friends who changed status. How can I get friends who are already online?

I have gone through syntax of FriendInfo, but can not figure out how to use it. Any small example of knowing some specific client is online or not will be really helpful.

Thank you!

ʇolɐǝz ǝɥʇ qoq
  • 717
  • 1
  • 15
  • 30
Game Dev
  • 19
  • 1
  • 7

2 Answers2

0

To get friends status updates you send a string array with their usernames to Photon.

friends = new List<string>() { "Ford", "Zaphod", "Marvin", "Eddie" };
chatClient.AddFriends(friends.ToArray());

For all friends online you'll receive an initial update with the current status for each to OnStatusUpdate() on your IChatClientListener interface.

OnStatusUpdate( string user, int status, bool gotMessage, object message )
{
    Console.WriteLine( "Status change for: " + user + " to: " + status );
}

Friends no status update is received for are offline.

photonians
  • 699
  • 1
  • 4
  • 12
  • this worked for me...its just its nt giving status update everytime. – Game Dev Mar 07 '15 at 06:21
  • It might help if you narrow down "not ... everytime" which is a circumstance we can not reproduce everytime ... ;)) – photonians Mar 16 '15 at 15:07
  • not everytime... means...every time I connect in photon chay I do not get update from all my online friends....so there is problem in showing current online friends. – Game Dev Mar 20 '15 at 04:32
0

You can call the event which updates the friends list via photon every 5 seconds. In that friend list in the should look something like this

foreach(PhotonFriendInfo friend in friendList)
        {
         Status.text=friend.IsOnline? "Online":"Offline";
         }

So call event which invokes this every 5 or 10 seconds

chethanv77777
  • 480
  • 9
  • 18