#ifndef SH_STREAM_TCP_H
#define SH_STREAM_TCP_H

#include <pistreampacker.h>

class SHStreamTCP: public PIStreamPacker {
	PIOBJECT_SUBCLASS(SHStreamTCP, PIStreamPacker)
public:
	SHStreamTCP(PIIODevice * dev = 0);

	uint ID() const {return id;}
	void setID(uint v) {id = v;}
	bool isCheckHeader() const {return check_hdr;}
	void setCheckHeader(bool yes) {check_hdr = yes;}
	uint lastRecID() const {return last_rid;}
	bool wasError() const {return was_error;}

	void send(const PIByteArray & data);

	EVENT1(packetReceivedSH, PIByteArray, data)

protected:
	void packetReceived(PIByteArray data) override;

	uint id, last_counter, send_counter, last_rid;
	bool check_hdr, was_error;

};

#endif // SH_STREAM_TCP_H
