#ifndef sPacket_h
#define sPacket_h
#include "misc.h"

class sPacket {
	private:
	size_t		 pay_len;
	unsigned char	*data;
	size_t           data_length;
	size_t		 size;
	size_t		 pos;
	uint8_t		 opcode;
	uint8_t		 proto;
	public:
static  int		 count;
 	int		 status;
	void		 Work 		(void) { };
static  int 		 Count 		( ) { return count; }	
			 sPacket 	(void);
			~sPacket	(void);
	bool		 readReset	(void);
	int 		 Read 		(class cSocket *Socket);	
	int 		 Send		(class cSocket *Socket);
	bool		 Full		(void) const { return status == 101; }
	size_t		 Unused		(void) const { return pay_len - pos - 1; }
	size_t		 Length		(void) const { return pay_len;    }
	uint8_t		 Command	(void) const { return opcode; }
	uint8_t		 Proto		(void) const { return proto; }
	void		 Proto		(uint8_t p);
	void		 Paylen		(size_t  p);
	void		 Opcode		(uint8_t p);
	bool 		 GET_HASH	(tHash &hash);
	float     	 GET_F4 	(void);
	uint32_t  	 GET_U4 	(void);
	uint16_t	 GET_U2 	(void);
	uint8_t 	 GET_U1 	(void);
	char		*GET_S2 	(void);
	void		 GET_BLIND	(unsigned);
	unsigned char   *DATA		(void);
	void		 Dump		(void) const;
	};
#endif
