How to fix duplicate messages

chay167
chay167
edited October 30 in Photon Chat

Hello! I'm using photon chat and whenever I send a message it always runs the method OnGetMessages() 2 times. I hope theres nothing wrong with my code but if there is here it is.


public void OnGetMessages(string channelName, string[] senders, object[] messages)
  {
    Messages.text = Messages.text + $"\n {senders[0]}: {messages[0]}";
    Debug.Log($"Message Recieved from {senders[0]}, {messages[0]}");
  }

Best Answer

  • JohnTube
    JohnTube mod
    Accepted Answer

    Hi @chay167,

    Thank you for choosing Photon!

    It's not clear if you are talking about publishing message into a public chat channel or sending private message.


    Make sure you are not sending twice.

    Make sure you have a single Photon Chat client (and single listener) in your application.

    Make sure you use different unique UserID per user and that you are not sending message directly to yourself (sender UserID == destination UserID).

Answers

  • JohnTube
    JohnTube mod
    Accepted Answer

    Hi @chay167,

    Thank you for choosing Photon!

    It's not clear if you are talking about publishing message into a public chat channel or sending private message.


    Make sure you are not sending twice.

    Make sure you have a single Photon Chat client (and single listener) in your application.

    Make sure you use different unique UserID per user and that you are not sending message directly to yourself (sender UserID == destination UserID).