How to use the @cometchat-pro/chat.CometChat.MessageListener function in @cometchat-pro/chat

To help you get started, we’ve selected a few @cometchat-pro/chat examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / lib / cometchat / ccManager.js View on Github external
static addMessageListener(dispatch) {
    CometChat.addMessageListener(
      this.LISTENER_KEY_MESSAGE,
      new CometChat.MessageListener({
        onTextMessageReceived: message => {
          this.handleMessage(message, dispatch);
        },
        onMediaMessageReceived: message => {
          this.handleMessage(message, dispatch);
        },
        onMessagesDelivered: (messageReceipt) => {
          this.handleMessageDelivered(messageReceipt, dispatch);
        },
        onMessagesRead: (messageReceipt) => {
          this.handleMessageRead(messageReceipt, dispatch);
        },
        onTypingStarted: (typingIndicator) => {
          this.handleStartTyping(typingIndicator,dispatch);
        },
        onTypingEnded: (typingIndicator) => {
github cometchat-pro-samples / javascript-reactjs-chat-app / src / components / cometchat / ChatBody.jsx View on Github external
]);
         
          if (index_in_history !== undefined) {
            msghistory[index_in_history]["deliveredAt"] =
              messageReceipt.deliveredAt;
            this.setState({ msghistory });
          }
        }
      })
    );

    var listenerID4 = LISTENER_RT_MSG_EDIT;

    CometChat.addMessageListener(
      listenerID4,
      new CometChat.MessageListener({
        onMessageEdited: message => {
          let msghistory = this.state.msghistory;
          let messageKey = _.findIndex(msghistory, function(m) {
            return m.id === message.id;
          });
          msghistory[messageKey] = message;
          this.setState({ msghistory });

          this.props.handleOnRecentMessageSent(message.id);
        }
      })
    );

    var listenerID5 = LISTENER_RT_MSG_DELETE;
    CometChat.addMessageListener(
      listenerID5,
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / components / message / CCMessageBox.js View on Github external
componentWillMount() {
    this.fetchfirstTimeMessage(this.props.activeUser.type,this.props.activeUser.id);
    CometChat.addMessageListener(
      "CHAT_BOX_LISTENER",
      new CometChat.MessageListener({
        onTextMessageReceived: message => {
          this.markAsRead(message);
        },
        onMediaMessageReceived: message => {
          this.markAsRead(message);
        }
      })
    );
  }