Attempting to set history length to zero so we dont get messages when we connect/reconnect

In ChatClient.AddFriends(string[] friends) I have changed the the parameters to include a historylength parameter of zero.

Dictionary<byte, object> parameters = new Dictionary<byte, object>
    {
        { ChatParameterCode.Friends, friends },
        { ChatParameterCode.HistoryLength, 0 }
    };

return this.chatPeer.SendOperation(ChatOperationCode.AddFriends, parameters, SendOptions.SendReliable);

I have logging to show this code is definitely being run, but the history is still coming through for the chats when I reconnect. Is there somewhere else that I need to set the historylength?

I had a look at the ChatClient.Connect method but couldn't find anywhere in there to set the historylength.

Any advice appreciated. Thanks.

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭

    Hi @hellohallo,

    Not sure why you are adding the parameter to the AddFriends operation. That operation does not accept that parameter.

    Here is how to handle history in Chat.

    Otherwise try setting chatClient.PrivateChatHistoryLength before connecting.

  • Thanks for your reply.

    Is PrivateChatHistoryLength supposed to be a variable in the ChatClient class? I couldn't seem to find it. I'm connecting like ths:

    chatClient.AuthValues = new Photon.Chat.AuthenticationValues(nickName);
    chatClient.Connect(PhotonNetwork.PhotonServerSettings.AppSettings.AppIdChat, PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion, chatClient.AuthValues);
    

    Could you let me know what to adjust to set the privatechathistorylength? much appreciated

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited February 21

    Hi @hellohallo,

    Not sure which version PUN you are using, please update to the latest.

    chatClient.PrivateChatHistoryLength = 0;
    chatClient.AuthValues = new Photon.Chat.AuthenticationValues(nickName);
    chatClient.Connect(PhotonNetwork.PhotonServerSettings.AppSettings.AppIdChat, PhotonNetwork.PhotonServerSettings.AppSettings.AppVersion, chatClient.AuthValues);
    


  • thanks. yes this was it the older version i'm using didnt have it