How to use the @cometchat-pro/chat.CometChat.sendMessage 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 / store / actions / cc_action.js View on Github external
return dispatch => {
      CometChat.sendMessage(textMessage).then(
        message => {
          return dispatch(updateMessage(uid, message, "sendText"));
        },
        error => {
          console.log("mesage callback error : " + JSON.stringify(error));
        }
      );
    };
  } else {
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / store / actions / cc_action.js View on Github external
return dispatch => {
    CometChat.sendMessage(mediaMessage).then(
      message => {
        return dispatch(updateMessage(uid, message, "sendText"));
      },
      error => {
        console.log("mesage callback error : " + JSON.stringify(error));
      }
    );
  };
};
github cometchat-pro-samples / javascript-reactjs-chat-app / src / components / cometchat / ChatBody.jsx View on Github external
receiverID = this.props.activeConversation.uid;
        receiverType = CometChat.RECEIVER_TYPE.USER;
      }

      var messageText = this.state.newMessage;
      var textMessage = new CometChat.TextMessage(
        receiverID,
        messageText,
        CometChat.MESSAGE_TYPE.TEXT,
        receiverType
      );

      if (this.state.editingMessageActive === true) {
        this.handleMessageUpdate(receiverID, receiverType, messageText);
      } else {
        CometChat.sendMessage(textMessage).then(
          message => {
            
            this.setState({
              newMessage: [],
              msghistory: [...this.state.msghistory, message]
            });
            
            this.scrollToBottom();
            this.props.handleOnRecentMessageSent(message.id);
          },
          error => {
            this.setState({ newMessage: [] });
          }
        );
      }
    }