package cn.net.cpzslibs.prot;

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

//注册用户信息
public class Prot103RegistInfo extends ProtBase {
	private final short iTaskCode103 = 103;
	public void dealProt(SocketCreate create, String sUserId, short iGender, short iAge, String sProfal, String sMobile)
			throws IOException {
		sendProt(create.getDos(), iTaskCode103, sUserId, iGender, iAge, sProfal, sMobile);
		recProt(create.getDis(), iTaskCode103);
	}

	private void recProt(DataInputStream dis, short iTaskCode) throws IOException {
		recHeader(dis);
		recFFFF(dis, iTaskCode);
	}

	/**
	 * 
	 * <br/>
	 * 2015-9-8上午10:31:28
	 * 
	 * @param dos
	 * @param iTaskCode
	 * @param userid
	 * @param iGender
	 *            0:男(默认) ;1:女
	 * @param iAge
	 *            0：60-70<br/>
	 *            1：70-80<br/>
	 *            2：80-90<br/>
	 *            3：90-00<br/>
	 *            4：00-10<br/>
	 * @param profal
	 *            30字节
	 * @param mobile
	 *            11字节
	 * @throws SocketTimeoutException
	 * @throws IOException
	 */
	private void sendProt(DataOutputStream dos, short iTaskCode, String userid, short iGender, short iAge,
			String profal, String mobile) throws SocketTimeoutException, IOException {
		byte[] sendUserIds = getSendBytes(userid, 12);// 发送用户名
		byte[] sendProfals = getSendBytes(profal, 30);
		byte[] sendMobiles = getSendBytes(mobile, 11);
		short iBodySize = (short) (countBodySize(sendUserIds, iGender, iAge, sendProfals, sendMobiles));
		sendHeader(dos, iTaskCode, iBodySize);
		dos.write(sendUserIds);
		dos.writeShort(iGender);
		dos.writeShort(iAge);
		dos.write(sendProfals);
		dos.write(sendMobiles);
		sendCheckCode(dos);

	}
}
