[Resolved][MMO CHAT] Private & Party Messages

Drewen
edited January 2011 in Photon Server
Hi everybody,

I am trying to create a chat system and I've found problems doing the private messages. For normal messages I used the normal channel event methods...but for private messages I don´t know what to do: everybody subscribed to the channel receives the message...

Any idea?


Thank you so much

Comments

  • Hi Drewen,
    The RaiseGenericEvent operation has a parameter "EventReceiver", possible values are defined in enumeration EventReceiver: ItemOwner and ItemSubscriber.
    For private messages send it to the ItemOwner.
  • Totally awesome...in 10 minutes I finished the private message system.

    Now I am gonna start the "party chat" system. My idea is to generate a partyId when a party is created...immediately after that, a channel with the group id is created and all the party members are subscribed to it. Then, all the party messages are published in the party channel. When the party has been disbanded, the channel is disposed.

    Is this correct? any suggestion? How many parties at the same time could I have with this system?

    Thank you so much! you are the best, guys!
  • Glad you like it :)

    The system you describe sounds good. How are you going to track if a party is disbanded? If this has any holes in it, the system could eat up memory after a while.

    How many parties you could have is impossible to guess. It depends on the hardware and the performance left on it and how busy the system is going to be.
  • I'm goona make 2 operations: DisbandParty and LeaveParty. DisbandParty could be requested by the party leader: the event will be published in the party channel and after that, the channel will be disposed.

    The LeaveParty could be requested by any party member. In this case, the player would be unsubscribed and after that, I'm gonna check the subscribers to that party channel: if it is 0 -> channel.dispose!

    That's the idea... let's see if it works!

    Thank you!
  • LeaveParty should also be calles automatically in a peer's OnDisconnect(), then you're safe.
  • Yeah! I forgot it!

    Thanks Tobias!
  • a chat channel as you describe it is basically what we do to manage the region-based interest (one region = one channel). Every peer uses it's response fiber to subscribe, so that you can send the event directly to the client (with Peer.PhotonPeer.SendEvent() - it skips another response fiber enqueue that Peer.PublishEvent() would do).

    What Tobias pointed out above (How to track if a party is disbanded) is pretty important and not to underestimate.
    I assume you have a dictionary with channels and that you remove the channel on dispose and add them when the player first joins. If you don't synchronize ALL join and leave operations for the whole dictionary it could happen that clients of the same group subscribe different channel instances: Player creates channel and while leaving again another player joins (dispose happens right before join). The next player creates a new channel instance and they end up in different instances.
  • Well, last week I finished the party system. The solution is something like this:

    - MmoGroupCache -> has all the parties in a dictionary
    - MmoGroup -> has all the subscriptions, a fiber, a leader Id, a channel and and ActionQueue (like the radar)

    When a group is created all members subscribe its channel and when they publish a message there, all the party members receive this message.
    When a party member leave the group, it unsubscribes itself from the party channel and a message is published to all members notifying that X has leaved the group.
    When there is one or less members in a group, the group is disbanded -> that means, the MmoGroup is disposed (and all subscriptions removed) and the group is removed from the MmoGroupCache.

    It works perfectly. Thank you so much for your help!

    Now, I´m gonna start with the DataBase connection...let's see what happen!