Search in sources :

Example 1 with EMCmdMessageBody

use of com.hyphenate.chat.EMCmdMessageBody in project SmartCampus by Vegen.

the class EaseDingMessageHelper method sendAckMessage.

public void sendAckMessage(EMMessage message) {
    if (!validateMessage(message)) {
        return;
    }
    if (message.isAcked()) {
        return;
    }
    // May a user login from multiple devices, so do not need to send the ack msg.
    if (EMClient.getInstance().getCurrentUser().equalsIgnoreCase(message.getFrom())) {
        return;
    }
    try {
        // cmd-type message will not store in native database.
        EMMessage msg = EMMessage.createSendMessage(EMMessage.Type.CMD);
        msg.setTo(message.getFrom());
        msg.setAttribute(KEY_CONVERSATION_ID, message.getTo());
        msg.setAttribute(KEY_DING_ACK, true);
        msg.addBody(new EMCmdMessageBody(message.getMsgId()));
        EMClient.getInstance().chatManager().sendMessage(msg);
        message.setAcked(true);
        EMLog.i(TAG, "Send the group ack cmd-type message.");
    } catch (Exception e) {
    }
}
Also used : EMCmdMessageBody(com.hyphenate.chat.EMCmdMessageBody) HyphenateException(com.hyphenate.exceptions.HyphenateException) EMMessage(com.hyphenate.chat.EMMessage)

Example 2 with EMCmdMessageBody

use of com.hyphenate.chat.EMCmdMessageBody in project SmartCampus by Vegen.

the class EaseDingMessageHelperTest method createDingAckMessage.

private EMMessage createDingAckMessage(String conversationId, String originalMsgId, String from) {
    EMAMessage _msg = EMAMessage.createSendMessage(from, "", null, EMMessage.ChatType.Chat.ordinal());
    EMMessage msg = new EMMessage(_msg);
    msg.setAttribute(KEY_CONVERSATION_ID, conversationId);
    msg.setAttribute(KEY_DING_ACK, true);
    msg.addBody(new EMCmdMessageBody(originalMsgId));
    return msg;
}
Also used : EMCmdMessageBody(com.hyphenate.chat.EMCmdMessageBody) EMAMessage(com.hyphenate.chat.adapter.message.EMAMessage) EMMessage(com.hyphenate.chat.EMMessage)

Aggregations

EMCmdMessageBody (com.hyphenate.chat.EMCmdMessageBody)2 EMMessage (com.hyphenate.chat.EMMessage)2 EMAMessage (com.hyphenate.chat.adapter.message.EMAMessage)1 HyphenateException (com.hyphenate.exceptions.HyphenateException)1