When joining room chat and group chat then sending a message, both channel received the message

So I have a room chat named Public and group chat named MyGroup. In my scenario, first I joined Public chat by default. And then later the user can join a group chat by clicking a button. But when I send a message in a Public channel or MyGroup channel both received the message. Is this expected behaviour?
PS: I’ve unsubscribed the AddMessage from Public channel when the user joined the MyGroup channel

No this is not expected; You are either sending the message to both channels; or on the receiving end not distinguishing arrived messages correctly. There is a bug on your client somewhere.

Also make sure you are using the latest Nakama Unity SDK + Nakama server.

1 Like

I’ve unsubscribed the event like in the Pirate Panic example but no luck. I thought it will stop receiving the message but it wasn’t. So I added some filter by make use of empty string from IApiChannelMessage to prevent it from spawning in the wrong chat box.

I had a similar issue with the stack golang + flutter and for now I also end up filtering on the client side.

Hello,
That’s not an issue. You have a single subscription on all user messages, something like this:

socket.onchannelmessage

You have to filter messages when you receive them:

  1. Have a look if the message is with code 0 (All messages sent by users.); Link to all codes you might get
  2. If it’s a group message it will contain group_id,
    if it’s a room message it will contain room_name.

With all this info you can show messages in the correct UI.