diff options
| author | Sebastian | 2010-05-12 19:42:27 +0200 |
|---|---|---|
| committer | Sebastian | 2010-05-12 19:42:27 +0200 |
| commit | ce3329047d378a14006ce74ec273ac59e3375303 (patch) | |
| tree | 782430f270b4c7aca1b35d5b7813518e3797c555 /src/net/pvsMsg.h | |
| download | pvs-ce3329047d378a14006ce74ec273ac59e3375303.tar.gz pvs-ce3329047d378a14006ce74ec273ac59e3375303.tar.xz pvs-ce3329047d378a14006ce74ec273ac59e3375303.zip | |
initial import of latest svn version
Diffstat (limited to 'src/net/pvsMsg.h')
| -rw-r--r-- | src/net/pvsMsg.h | 73 |
1 files changed, 73 insertions, 0 deletions
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 <QtCore/QString> + +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_ */ |
