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

com.hn.im.easemob.comm.body.AudioMessageBody 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.hn.im.easemob.comm.constant.MsgType;

import java.util.Map;

public class AudioMessageBody extends MessageBody {
	private String url;
	private String filename;
	private String secret;
	private Long length;

	public AudioMessageBody(String targetType, String[] targets, String from, Map ext, String url, String filename, String secret, Long length) {
		super(targetType, targets, from, ext);
		this.url = url;
		this.filename = filename;
		this.secret = secret;
		this.length = length;
	}

	public String getUrl() {
		return url;
	}

	public String getFilename() {
		return filename;
	}

	public String getSecret() {
		return secret;
	}

	public Long getLength() {
		return length;
	}

	public ContainerNode getBody() {
		if(!this.isInit()){
            this.getMsgBody().put("type", MsgType.AUDIO);
            this.getMsgBody().put("url", url);
            this.getMsgBody().put("filename", filename);
            this.getMsgBody().put("secret", secret);
            this.getMsgBody().put("length", length);
            this.setInit(true);
		}

		return this.getMsgBody();
	}

	@Override
	public Boolean validate() {
		return super.validate() && StrUtil.isNotBlank(url) && StrUtil.isNotBlank(filename) && StrUtil.isNotBlank(secret) && null != length;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy