From ce3329047d378a14006ce74ec273ac59e3375303 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 12 May 2010 19:42:27 +0200 Subject: initial import of latest svn version --- src/net/pvsMsg.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 src/net/pvsMsg.h (limited to 'src/net/pvsMsg.h') diff --git a/src/net/pvsMsg.h b/src/net/pvsMsg.h new file mode 100644 index 0000000..6fbcd99 --- /dev/null +++ b/src/net/pvsMsg.h @@ -0,0 +1,73 @@ +/* + * pvsMsg.h + * + * Created on: 08.01.2010 + * Author: sr + */ + +#ifndef PVSMSG_H_ +#define PVSMSG_H_ + + +#include + +enum PVSMsgType +{ + PVSCOMMAND = 'C', + PVSMESSAGE = 'M', + PVSLOGIN = 'L', + PVSDAEMON = 'D', + PVSUNKNOWN = 'U' +}; + +class PVSServerConnection; +class PVSListenServer; +class PVSClientConnection; +class QAbstractSocket; + +class PVSMsg +{ +public: + friend class PVSServerConnection; + friend class PVSListenServer; + friend class PVSClientConnection; + + PVSMsg(); + PVSMsg(PVSMsgType type, QString _ident, QString msg, int recID = 0); + PVSMsg(PVSMsg const& copyMe); + ~PVSMsg(); + + int readMessage(QAbstractSocket* sock, bool udp = false); ///< -1 = error, 0 = incomplete, 1 = complete + unsigned int getLength() + { + return _msgString.size(); + }; + void setIdent(QString ident); + QString getIdent(); + void setMessage(QString text); + QString getMessage(); + PVSMsgType getType() { return _msgType; } + bool getBinaryData(char*& data, int& dataLen); ///< get binary representation of this PVSmsg + + unsigned int getRecID() { return _recID; } + int getSndID() { return _sndID; } + QString getRemoteIp() { return _remoteIp; } + bool isMsgComplete() { return _buffFill > 0 && _buffFill == _buffLen; } + +private: + void setSndID(int id); + void setRecID(int id); + bool makeSndBuff(); + PVSMsgType _msgType; ///< type of message (command, message, login, daemon) + QString _msgIdent; ///< message ident + QString _msgString; ///< message string + char *_buffer; ///< receive buffer + int _buffLen; ///< size of complete message in bytes + int _buffFill; ///< actual number of bytes in buffer + + int _sndID; + int _recID; + QString _remoteIp; +}; + +#endif /* PVSMSG_H_ */ -- cgit v1.2.3-55-g7522