Java Code Examples for com.hyphenate.chat.EMMessage#setAttribute()

The following examples show how to use com.hyphenate.chat.EMMessage#setAttribute() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EaseChatFragment.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
/**
 * send @ message, only support group chat message
 * @param content
 */
@SuppressWarnings("ConstantConditions")
private void sendAtMessage(String content){
    if(chatType != EaseConstant.CHATTYPE_GROUP){
        EMLog.e(TAG, "only support group chat message");
        return;
    }
    EMMessage message = EMMessage.createTxtSendMessage(content, toChatUsername);
    EMGroup group = EMClient.getInstance().groupManager().getGroup(toChatUsername);
    if(EMClient.getInstance().getCurrentUser().equals(group.getOwner()) && EaseAtMessageHelper.get().containsAtAll(content)){
        message.setAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG, EaseConstant.MESSAGE_ATTR_VALUE_AT_MSG_ALL);
    }else {
        message.setAttribute(EaseConstant.MESSAGE_ATTR_AT_MSG,
                EaseAtMessageHelper.get().atListToJsonArray(EaseAtMessageHelper.get().getAtMessageUsernames(content)));
    }
    sendMessage(message);
    
}
 
Example 2
Source File: EaseCommonUtils.java    From Social with Apache License 2.0 5 votes vote down vote up
public static EMMessage createExpressionMessage(String toChatUsername, String expressioName, String identityCode){
    EMMessage message = EMMessage.createTxtSendMessage("["+expressioName+"]", toChatUsername);
       if(identityCode != null){
           message.setAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, identityCode);
       }
       message.setAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, true);
       return message;
}
 
Example 3
Source File: EaseCommonUtils.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
public static EMMessage createExpressionMessage(String toChatUsername, String expressioName, String identityCode){
    EMMessage message = EMMessage.createTxtSendMessage("["+expressioName+"]", toChatUsername);
       if(identityCode != null){
           message.setAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, identityCode);
       }
       message.setAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, true);
       return message;
}
 
Example 4
Source File: EaseCommonUtils.java    From nono-android with GNU General Public License v3.0 5 votes vote down vote up
public static EMMessage createExpressionMessage(String toChatUsername, String expressioName, String identityCode){
    EMMessage message = EMMessage.createTxtSendMessage("["+expressioName+"]", toChatUsername);
       if(identityCode != null){
           message.setAttribute(EaseConstant.MESSAGE_ATTR_EXPRESSION_ID, identityCode);
       }
       message.setAttribute(EaseConstant.MESSAGE_ATTR_IS_BIG_EXPRESSION, true);
       return message;
}
 
Example 5
Source File: HxChatPresenter.java    From FamilyChat with Apache License 2.0 5 votes vote down vote up
/**
 * 发送文本消息
 */
public void sendTextMessage(EMConversation.EMConversationType conType, String conId, String message)
{
    EMMessage emMessage = HxChatHelper.getInstance().createTextMessage(getChatTypeFromConType(conType), conId, message);
    emMessage.setAttribute(HxMsgAttrConstant.TXT_ATTR_KEY, HxMsgAttrConstant.NORMAL_TEXT_MSG);
    emMessage.setMessageStatusCallback(new MessageStatusCallBack(emMessage));
    mViewImpl.addNewMessage(emMessage, true);
    HxChatHelper.getInstance().sendMessage(emMessage);
}