23 |
23 |
24 #if _MSC_VER > 1000 |
24 #if _MSC_VER > 1000 |
25 #pragma once |
25 #pragma once |
26 #endif // _MSC_VER > 1000 |
26 #endif // _MSC_VER > 1000 |
27 |
27 |
|
28 #define DECODE_MESSAGE_NOT_FOUND (0) // enough bytes, but message cannot be decoded |
|
29 #define DECODE_MESSAGE_FOUND (1) // enough bytes, and message found |
|
30 #define DECODE_NOT_ENOUGH_BYTES_TO_SEARCH (2) // not enough bytes to do compare |
|
31 |
28 class CBaseProtocol |
32 class CBaseProtocol |
29 { |
33 { |
30 public: |
34 public: |
31 CBaseProtocol(); |
35 CBaseProtocol(); |
32 virtual ~CBaseProtocol(); |
36 virtual ~CBaseProtocol(); |
33 |
37 |
34 // used to decode a message into header/message parts |
38 // used to decode a message into header/message parts |
35 virtual BOOL DecodeMessage(BYTE* fullMessage, DWORD& fullLength, BYTE& msgId, BYTE*& rawMessage, DWORD& rawLength)=0; |
39 virtual int DecodeMessage(BYTE* fullMessage, DWORD& fullLength, BYTE& msgId, BYTE*& rawMessage, DWORD& rawLength)=0; |
36 |
40 |
37 // used to encode a raw message (prefixes any protocol headers) |
41 // used to encode a raw message (prefixes any protocol headers) |
38 virtual DWORD EncodeMessage(BYTE* rawMessage, DWORD rawLength, BYTE protocolVersion, BYTE msgId, BYTE* fullMessage, DWORD maxFullLength)=0; |
42 virtual DWORD EncodeMessage(BYTE* rawMessage, DWORD rawLength, BYTE protocolVersion, BYTE msgId, BYTE* fullMessage, DWORD maxFullLength)=0; |
39 |
43 |
40 // used to query how many bytes the header is so the caller can allocate enough memory |
44 // used to query how many bytes the header is so the caller can allocate enough memory |