summaryrefslogtreecommitdiff
path: root/comm/MsgStream.h
diff options
context:
space:
mode:
Diffstat (limited to 'comm/MsgStream.h')
-rw-r--r--comm/MsgStream.h69
1 files changed, 47 insertions, 22 deletions
diff --git a/comm/MsgStream.h b/comm/MsgStream.h
index bfa8e78..b33437a 100644
--- a/comm/MsgStream.h
+++ b/comm/MsgStream.h
@@ -20,51 +20,76 @@
#include "MsgBuffer.h"
class UchMessage;
-class UchMsgStream : public UchStream {
-private:
-
+class UchBufStream : public UchStream {
protected:
- UchMsgBuffer InBuffer;
- int InSize;
- UchMsgBuffer OutBuffer;
+ UchMsgBuffer InBuffer;
+ UchMsgBuffer OutBuffer;
int OutSize;
+ bool Sync;
+
+ UchBufStream (const UchBufStream&);
+ int ReadInput ();
+ void HandleWrite ();
+
+ void WriteLong (lword);
+ void WriteShort (sword);
+ void WriteByte (byte);
+ void WriteChar (char);
+ void WriteString (const char*);
+ void WriteBuf (const byte*, int);
+
+
+ void ReadLong (lword&);
+ void ReadShort (sword&);
+ void ReadByte (byte&);
+ void ReadChar (char&);
+ void ReadString (char*);
+ void ReadString (CcuString&);
+ void ReadBuf (byte*, int);
+
+public:
+ UchBufStream (UchAddress* = 0, UchAddress* = 0);
+ ~UchBufStream ();
+
+ void InputBuffer (int min, int grow, int max);
+ void OutputBuffer (int min, int grow, int max);
+inline bool GetSyncMode () { return Sync; }
+inline void SetSyncMode (bool s) { Sync = s; Flush (); }
+inline void FlushSize (int n) { OutSize = n; }
+virtual void Flush ();
+
+virtual void Closing (bool);
+};
+
+class UchMsgStream : public UchBufStream {
+protected:
enum STATE { WAITING, GOT_TYPE, GOT_LENGTH, DONE};
enum TYPE { MSG = 1, ASK, ANS, SYNC, ASYNC, OK };
STATE State;
bool BufferedMessages;
UchMsgBuffer Buffered;
- bool WaitingForAnswer;
bool WaitingReply;
int InLength;
byte InType;
- bool Sync;
- void ProcessInput (UchMsgBuffer&, bool);
- int ReadInput ();
+ UchMessage* Process (UchMsgBuffer&, bool);
+ UchMsgStream (const UchMsgStream&);
+ void WriteMsg (UchMessage&);
+ bool ReadMsg (UchMessage&);
public:
- UchMsgStream (const UchMsgStream&);
UchMsgStream (UchAddress* = 0, UchAddress* = 0);
~UchMsgStream ();
- void InputBuffer (int min, int grow, int max);
- void OutputBuffer (int min, int grow, int max);
-inline void FlushSize (int n) { OutSize = n; }
UchChannel* Copy () const;
void HandleRead ();
- void HandleWrite ();
bool HandleSelect ();
-inline bool GetSyncMode () { return Sync; }
-inline void SetSyncMode (bool s) { Sync = s; Flush (); }
virtual bool NewMessage (UchMsgBuffer&, bool);
virtual UchMessage* ConvertAnswer (UchMsgBuffer&);
-virtual void Delete ();
- void Send (UchMessage&, bool = FALSE);
+ void Send (UchMessage&, bool = false);
UchMessage* Ask (UchMessage&);
void Reply (UchMessage&);
- void Flush ();
- void Send (UchMsgBuffer&, bool = FALSE);
+ void Send (UchMsgBuffer&, bool = false);
};
#endif /* MsgStream_H_ */
-