can i get Private chat history ?

hello,
i need to private chat history in photon chat.
Is this possible? if yes then how and if no then why ?
please help me if any one have idea.

thank you.

Comments

  • JohnTubeJohnTube mod
    edited March 19
    Hi @sonal_dhole2,

    Where do you need the private chat history?
    In client side or in chat webhooks?

    What do you need the chat history for?

    If user A sends private message(s) to user B while user B is disconnected, user B will receive the last X messages once connected as long as user A is still connected.
    I think X is 100, it's the maximum history size per channel (private or public).

    If this is not what you are looking for, you can always use public channels as "private channels": use special channel name (e.g. "-") and the channel can be subscribed only by two users (e.g. userA and user B ).
  • i need private chat history in my room.
    e.g. if two player A and B coming to single room and doing chat, after that player B left the room and again join the same room ,then i need the previous private chat of them.
    is this possible ?
  • JohnTubeJohnTube mod
    edited April 18
    Hi @sonal_dhole2,

    Photon Chat has channels and does not have rooms.
    Rooms are available in PUN or Photon Realtime.

    The server keeps the last 100 messages exchanged per channel as long as player A or player B stay connected to Photon Chat.
    The client API or SDK may cache the messages locally for more than 100 messages.
    You can get those using:
    string privateChannelName = chatClient.GetPrivateChannelNameByUser(remoteUser);
    ChatChannel privateChannel;
    if (chatClient.TryGetChannel(privateChannelName, true, out privateChannel)) 
    {
                    List messages = privateChannel.Messages;
                    List senders = privateChannel.Senders;
    }
  • i can't able to get private chat channel
    chatClient.TryGetChannel(privateChannelName, true, out privateChannel)
    at this point.
  • Hi @sonal_dhole2,

    This probably means that the client did not receive any message from that user.
  • but in this method
    public void OnPrivateMessage(string sender, object message, String channelName)
    it receives the message then how can it possible?
  • Hi @sonal_dhole2,

    When are you using the code snippet?
    At which point?
    it receives the message then how can it possible?
    Is the sender equal the local UserId? are you receiving your own message?
  • Is the sender equal the local UserId?
    it receives messages from both if the sender is a local user or another one.

    are you receiving your own message?
    receive messages of both of them who are in private chat.

    my scenario is that

    I am connected to chat client -----> chat with person as private chat -----> now I am disconnecting from chatclient ----> again connect to chat client and come online ------> at that time I can't get private chat history of with that person.
  • Hi @sonal_dhole2,

    it receives messages from both if the sender is a local user or another one.
    [...]
    receive messages of both of them who are in private chat.
    Yes, that's the expected behaviour, if you send a private or public message you will also receive it yourself.

    In file "Assets\Photon\PhotonChat\Code\ChatClient.cs", line 232, inside ChatClient.Connect, we clear private channels.
    this.PrivateChannels.Clear();
    You can comment out this line and see if it helps.
Sign In or Register to comment.