helper.java

来自「java版QQ聊天系统」· Java 代码 · 共 28 行

JAVA
28
字号
package com.AUG21.ProtocolEncapsulation;

import java.io.*;

public class Helper {

	public byte[] wrap(String input) throws IOException {// 把传进来的字符串加包头,打包
		BussinessOuthelp outhelp = new BussinessOuthelp(300);
		outhelp.writeString(""/*获取账号*/, 6);
		outhelp.writeInt(/*password*/1);
		outhelp.writeString(""/*获取系统时间*/, 14);
		//outhelp.writeString(input, 150);
		outhelp.writeString(Config.END_SYMBOL, 4);
		return outhelp.getBytes();
	}

	public DataMessage unwrap(byte[] buf) throws IOException {// 收到包的解包操作
		BussinessInHelper helper = new BussinessInHelper(buf);
		new NetStruck(helper.getIP(), helper.getInt(), helper.getInt(), helper
				.getLong());

		return new DataMessage(helper.getString(6), helper.getInt(), helper
				.getString(14), helper.getString(150));

	}

}

⌨️ 快捷键说明

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