Implementing Private Chat in MMO Demo

Oayhan
Oayhan ✭✭
edited July 2011 in Photon Server
I'm trying to implement a friend system which involves a private chat system. I keep the ID of corresponding database row both in server side and client side, but how can I send the message to that specific person? Do I have to keep a list of peers explicitly on server side, or is there an easier way of doing this?

Comments

  • if you only want to send a message to a specific client from another one then it would be the best option to keep all connected peers on the server in a list or something where you can easily find them, dictionary, hashtable or whatever you prefer. Make sure the Key does not already exist or you'll get a duplication error and nothing will happen also its a good idea to add them as early as possible during the login/connection phase.
  • you can send events directly to another peer by targeting the owner of the other's avatar with RaiseGenericEvent.