How to use the @cometchat-pro/chat.CometChat.MediaMessage 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 / components / cometchat / ChatBody.jsx View on Github external
}

    let messageType = CometChat.MESSAGE_TYPE.MEDIA;

    if (fileType === MESSAGE_TYPE_IMAGE)
      messageType = CometChat.MESSAGE_TYPE.IMAGE;
    else if (fileType === MESSAGE_TYPE_VIDEO)
      messageType = CometChat.MESSAGE_TYPE.VIDEO;
    else if (fileType === MESSAGE_TYPE_AUDIO)
      messageType = CometChat.MESSAGE_TYPE.AUDIO;
    else if (fileType === MESSAGE_TYPE_FILE)
      messageType = CometChat.MESSAGE_TYPE.FILE;

    var file = document.getElementById("attachment-type-" + fileType).files[0];

    var mediaMessage = new CometChat.MediaMessage(
      otherUID,
      file,
      messageType,
      receiverType
    );
    CometChat.sendMediaMessage(mediaMessage).then(
      message => {
        // Message sent successfully.
        this.setState({
          showAttachmentOptions: !this.state.showAttachmentOptions,
          msghistory: [...this.state.msghistory, message]
        });
        this.scrollToBottom();
        this.props.handleOnRecentMessageSent(message.id);
      },
      error => {
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / lib / cometchat / ccManager.js View on Github external
static getMediaMessage(uid, file, msgType,mediaType) {
    if (msgType == "user") {
      return new CometChat.MediaMessage(uid, file, mediaType, CometChat.RECEIVER_TYPE.USER);
    } else {
      return new CometChat.MediaMessage(uid, file, mediaType, CometChat.RECEIVER_TYPE.GROUP);
    }
  }
github cometchat-pro-samples / javascript-reactjs-chat-app / src / js / lib / cometchat / ccManager.js View on Github external
static getMediaMessage(uid, file, msgType,mediaType) {
    if (msgType == "user") {
      return new CometChat.MediaMessage(uid, file, mediaType, CometChat.RECEIVER_TYPE.USER);
    } else {
      return new CometChat.MediaMessage(uid, file, mediaType, CometChat.RECEIVER_TYPE.GROUP);
    }
  }