⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 connectrequest.java

📁 移动empp网关
💻 JAVA
字号:
package cn.madhouse.gateway.empp.msgformat;

import cn.madhouse.gateway.empp.util.Tools;

public class ConnectRequest extends Message {

	private String accountId;
	private String authenticatorSource;
	private Integer version;
	private Integer timestamp;
	
	public ConnectRequest(
			String accountId, String authenticatorSource, Integer version, Integer timestamp) {
		this.commandId = Message.EMPP_CONNECT;
		this.sequenceId = Message.genSeqId();
		this.accountId = accountId;
		this.authenticatorSource = authenticatorSource;
		this.version = version;
		this.timestamp = timestamp;
	}
	
	public byte[] toByte() {
		String timestampStr = timestamp.toString();
		if(timestampStr.length() < 10) timestampStr = "0" + timestampStr;
		
		byte[] accountIdBTmp = accountId.getBytes();
		byte[] authenticatorSourceBTtmp = authenticatorSource.getBytes();
		byte[] timestampBTmp = timestampStr.getBytes();
		
		byte[] totalLengthB = Tools.int2byte(54);
		byte[] commandIdB = Tools.int2byte(commandId);
		byte[] sequenceIdB = Tools.int2byte(sequenceId);
		
		byte[] accountIdB = new byte[21];
		System.arraycopy(accountIdBTmp,0,accountIdB,0,accountIdBTmp.length);
		
		byte[] tmp = new byte[accountIdBTmp.length+9+authenticatorSourceBTtmp.length+timestampBTmp.length];
		System.arraycopy(accountIdBTmp,0,tmp,0,accountIdBTmp.length);
		System.arraycopy(authenticatorSourceBTtmp,0,tmp,accountIdBTmp.length+9,authenticatorSourceBTtmp.length);
		System.arraycopy(timestampBTmp,0,tmp,accountIdBTmp.length+9+authenticatorSourceBTtmp.length,timestampBTmp.length);
		byte[] authenticatorSourceB = Tools.md5(tmp);
		
		byte[] versionB = new byte[1];versionB[0] = version.byteValue();
		byte[] timestampB = Tools.int2byte(timestamp);
		
		byte[] b = new byte[54];
		System.arraycopy(totalLengthB,0,b,0,4);
		System.arraycopy(commandIdB,0,b,4,4);
		System.arraycopy(sequenceIdB,0,b,8,4);
		System.arraycopy(accountIdB,0,b,12,21);
		System.arraycopy(authenticatorSourceB,0,b,33,16);
		System.arraycopy(versionB,0,b,49,1);
		System.arraycopy(timestampB,0,b,50,4);
		
		return b;
	}
	
	public String getAccountId() {
		return accountId;
	}
	public String getAuthenticatorSource() {
		return authenticatorSource;
	}
	public Integer getTimestamp() {
		return timestamp;
	}
	public Integer getVersion() {
		return version;
	}
	public void setAccountId(String accountId) {
		this.accountId = accountId;
	}
	public void setAuthenticatorSource(String authenticatorSource) {
		this.authenticatorSource = authenticatorSource;
	}
	public void setTimestamp(Integer timestamp) {
		this.timestamp = timestamp;
	}
	public void setVersion(Integer version) {
		this.version = version;
	}
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -