2

When am sending new message it goes to all the distinct group channel, and it shouldn't be like this by default. Any suggestion appreciated.

For messaging part I have to array to store previous and new messages and load it when it is need.

The language is used is react.js and it is for simple web-app.

sendMessage(message) {
const data = '';
const customType = '';
this.state.currentChannel.sendUserMessage(message, data, customType, (mess, error) => {
  if (error) {
    console.error(`error sending message: ${error}`);
    return;
  }
  console.log(`message sent!! ${mess}`);
  console.log(mess);
  const messagesState = this.state.messages;
  messagesState.push(mess);
  this.setState({
    messages: messagesState,
  });
});

}

Is there anything wrong in this part ?!

Milan
  • 152
  • 1
  • 14

2 Answers2

1

Your Channel Handler receives all incoming messages. You have to check if the message's channel corresponds to the one you're currently entered in.

So, in onMessageReceived,

if (channel.url == myChannelUrl) {
    // Add the message to myChannel's message list.
}
terryk
  • 116
  • 7
1

Just add an empty array before each channel handler.

message = [];
channelHandler = currentChannel;
Radoslav Naidenov
  • 747
  • 1
  • 5
  • 12