package cn.net.cpzslibs.prot.handset;

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

import cn.net.cpzslibs.prot.ProtBase;
import cn.net.cpzslibs.prot.SocketCreate;

/**
 * 更新汽配产品列表的numberId
 * @author zwj
 *
 * 2015-8-3
 */
public class Prot28UpCarProductNId extends ProtBase {
	private final short iTaskCode28 = 28;

	public void dealProt(SocketCreate create, long iProductId, String sNId) throws SocketTimeoutException, IOException {
		sendProt(create.getDos(), iTaskCode28, iProductId, sNId);
		recProt(create.getDis(), iTaskCode28);
	}

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

	private void sendProt(DataOutputStream dos, short iTaskCode, long iProductId, String sNId)
			throws SocketTimeoutException, IOException {
		byte[] NIds = sNId.getBytes("UTF-8");
		short iNidSize = (short) NIds.length;
		short iBodySize = countBodySize(iProductId, iNidSize, sNId);
		sendHeader(dos, iTaskCode, iBodySize);
		sendiProductId(dos, iProductId);
		dos.writeShort(iNidSize);
		dos.write(NIds);
		sendCheckCode(dos);
	}
}
