package cn.net.cpzslibs.prot;

import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.SocketTimeoutException;

public class Prot102Register extends ProtBase{
	private final short iTaskCode102 = 102;
	public void dealProt(SocketCreate create, String userid, String password) throws IOException {
		sendProt(create.getDos(), iTaskCode102, userid, password);
		recProt(create.getDis(), iTaskCode102);
	}

	public boolean isHaveUserName(){
		return getiRecErrcode()==1062;
	}
	
	private void recProt(DataInputStream dis, short iTaskCode) throws IOException {
		recHeader(dis);
		recFFFF(dis, iTaskCode);
	}
	private void sendProt(DataOutputStream dos, short iTaskCode, String userid, String password)
			throws SocketTimeoutException, IOException {
			byte[] sendUserIds = getSendBytes(userid, 12);// 发送用户名
			byte[] sendPwds = getSendBytes(password, 8);// 密码
			short iBodySize = (short) (countBodySize(sendUserIds,password));
			sendHeader(dos, iTaskCode, iBodySize);
			dos.write(sendUserIds);
			dos.write(sendPwds);
			sendCheckCode(dos);

	}
}
