com.hn.im.easemob.comm.body.TextMessageBody Maven / Gradle / Ivy
package com.hn.im.easemob.comm.body;
import com.fasterxml.jackson.databind.node.ContainerNode;
import com.fasterxml.jackson.databind.node.JsonNodeFactory;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.hn.im.easemob.comm.constant.MsgType;
import cn.hutool.core.util.StrUtil;
import java.util.Map;
public class TextMessageBody extends MessageBody {
private String msg;
public TextMessageBody(String targetType, String[] targets, String from, Map ext, String msg) {
super(targetType, targets, from, ext);
this.msg = msg;
}
public String getMsg() {
return msg;
}
public ContainerNode> getBody() {
if(!isInit()){
ObjectNode objectNode=getMsgBody();
ObjectNode msgNode= JsonNodeFactory.instance.objectNode();
msgNode.put("type", MsgType.TEXT);
msgNode.put("msg", msg);
objectNode.put("msg", msgNode);
this.setInit(true);
}
return this.getMsgBody();
}
public Boolean validate() {
return super.validate() && StrUtil.isNotBlank(msg);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy