Clearing Chat message caches when leaving a Realtime room

This discussion was created from comments split from: Photon Chat to invite friend to room?.

Comments

  • @Kaiserludi hello, and everyone in the forum.

    It's been a while since this topic was written here, but now I'm working on something similar related and I'm desperate already.

    I happen to be using photon realtime and also photon chat to send private messages and set up teams. My idea is not only to tell them which room they have to go to, I want to form teams in the Loby, see their avatars, invite other members there, so I send invitations that can be accepted or rejected. then I send my character, others send theirs, even if they change their character I send messages that they updated, in short all that system of team creations like Pugb Mobil, brawl stars and many other games do.

    The point is that all that works correctly, the problem is like in cache. Somehow let's say I even close the game, and when I open it I get private messages that are not being invited, every time for example I enter a room and leave, I get the members of the previous team in which I am no longer. I give him to leave the team and I get the message again after a while, it is as if I recovered the previous messages. even I get messages of "your friend has denied the request" without me sending them recently, that is, I requested the denial and that's it, but after a while I disconnect and enter again and I repeat the message over and over again.

    I have tried when a message arrives to clean the channel but nothing, it doesn't work, it keeps happening to me.

    public void OnPrivateMessage(string sender, object message, string channelName)
    {
    this.chatClient.PrivateChannels[channelName].ClearMessages();
    ...


    I was reading that as long as one of the two is online the conversation is kept and sent to the newly connected one, that it is only deleted when both are offline. can you help me please? any ideas?
  • Hi @Serge.

    The thread in which you have posted, is located in the forum area for the C++ and objective C clients.

    Your code snippet looks like you are using a C# client.

    I have therefore moved your question into a separate thread in the .NET area of the forum, so that our .NET client engineers like @tobias and @JohnTube see it.
  • Hi @Serge,

    Thank you for choosing Photon!
    I have tried when a message arrives to clean the channel but nothing, it doesn't work, it keeps happening to me.
    You are only clearing local messages not server side ones.
    as long as one of the two is online the conversation is kept and sent to the newly connected one, that it is only deleted when both are offline. can you help me please? any ideas?
    Yes that's the expected behaviour.

    Currently in Photon Chat, there is no way to remove or clear messages from history.
    The server will keep the last 100 messages and resend them to users when they subscribe (or connect for private messages) as long as the channel is still alive on the server.

    I think that if you switch to public channels for sending the meta/control messages you can have more power of things: e.g. create new public channels 'per session per user'? make use of LastMsgId to stop receiving already received messages.
    For private messages you could discard already received ones. Although we do no expose the message ID per private event received you could get it from the event itself.

    Also if you could switch to sending some messages via Photon Realtime inside rooms when both target and sender are joined to the same room, you could make use of cached events.

    @Kaiserludi
    it turns out it's not a C#/.NET specific question.
    Feel free to share your opinion on this.
  • As a rule of thumb I recommend to send all messages to other clients inside the same room via Photon Realtime and to send all messages to other clients, which are not inside the same room, via Photon Chat, independently of the message type (no matter if it is a text chat message or game data that is not directly displayed to the player), as both products support the same set of data types.