All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hn.im.easemob.comm.body.CmdMessageBody Maven / Gradle / Ivy

There is a newer version: 1.0.18
Show newest version
package com.hn.im.easemob.comm.body;

import cn.hutool.core.util.StrUtil;
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 java.util.Map;

public class CmdMessageBody extends MessageBody {
	private String msg;

	public CmdMessageBody(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.CMD);
        	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