diff options
Diffstat (limited to 'lib/server/Protocol.h')
-rw-r--r-- | lib/server/Protocol.h | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/lib/server/Protocol.h b/lib/server/Protocol.h index e037e33c..dc660ad5 100644 --- a/lib/server/Protocol.h +++ b/lib/server/Protocol.h @@ -12,12 +12,22 @@ #include <sys/types.h> +<<<<<<< HEAD class IOStream; #include "ProtocolObject.h" +======= +>>>>>>> 0.12 #include <memory> #include <vector> #include <string> +<<<<<<< HEAD +======= +#include "Message.h" + +class IOStream; + +>>>>>>> 0.12 // default timeout is 15 minutes #define PROTOCOL_DEFAULT_TIMEOUT (15*60*1000) // 16 default maximum object size -- should be enough @@ -40,11 +50,22 @@ public: private: Protocol(const Protocol &rToCopy); +<<<<<<< HEAD public: void Handshake(); std::auto_ptr<ProtocolObject> Receive(); void Send(const ProtocolObject &rObject); +======= +protected: + // Unsafe to make public, as they may allow sending objects + // from a different protocol. The derived class prevents this. + std::auto_ptr<Message> ReceiveInternal(); + void SendInternal(const Message &rObject); + +public: + void Handshake(); +>>>>>>> 0.12 std::auto_ptr<IOStream> ReceiveStream(); void SendStream(IOStream &rStream); @@ -54,8 +75,11 @@ public: UnknownError = 0 }; +<<<<<<< HEAD bool GetLastError(int &rTypeOut, int &rSubTypeOut); +======= +>>>>>>> 0.12 // -------------------------------------------------------------------------- // // Function @@ -87,7 +111,11 @@ public: // -------------------------------------------------------------------------- void SetMaxObjectSize(unsigned int NewMaxObjSize) {mMaxObjectSize = NewMaxObjSize;} +<<<<<<< HEAD // For ProtocolObject derived classes +======= + // For Message derived classes +>>>>>>> 0.12 void Read(void *Buffer, int Size); void Read(std::string &rOut, int Size); void Read(int64_t &rOut); @@ -168,11 +196,23 @@ public: { ProtocolStream_SizeUncertain = 0xffffffff }; +<<<<<<< HEAD protected: virtual std::auto_ptr<ProtocolObject> MakeProtocolObject(int ObjType) = 0; virtual const char *GetIdentString() = 0; void SetError(int Type, int SubType) {mLastErrorType = Type; mLastErrorSubType = SubType;} +======= + bool GetLogToSysLog() { return mLogToSysLog; } + FILE *GetLogToFile() { return mLogToFile; } + void SetLogToSysLog(bool Log = false) {mLogToSysLog = Log;} + void SetLogToFile(FILE *File = 0) {mLogToFile = File;} + +protected: + virtual std::auto_ptr<Message> MakeMessage(int ObjType) = 0; + virtual const char *GetProtocolIdentString() = 0; + +>>>>>>> 0.12 void CheckAndReadHdr(void *hdr); // don't use type here to avoid dependency // Will be used for logging @@ -183,7 +223,10 @@ private: void EnsureBufferAllocated(int Size); int SendStreamSendBlock(uint8_t *Block, int BytesInBlock); +<<<<<<< HEAD private: +======= +>>>>>>> 0.12 IOStream &mrStream; bool mHandshakeDone; unsigned int mMaxObjectSize; @@ -193,8 +236,17 @@ private: int mReadOffset; int mWriteOffset; int mValidDataSize; +<<<<<<< HEAD int mLastErrorType; int mLastErrorSubType; +======= + bool mLogToSysLog; + FILE *mLogToFile; +}; + +class ProtocolContext +{ +>>>>>>> 0.12 }; #endif // PROTOCOL__H |