/* * The Unix Channel * * by Michel Beaudouin-Lafon * * Copyright 1990-1997 * Laboratoire de Recherche en Informatique (LRI) * * Message streams * * $Id$ * $CurLog$ */ #ifndef MsgStream_H_ #define MsgStream_H_ #include "BufStream.h" class IvlMessage; class IvlMsgStream : public IvlBufStream { protected: enum STATE { WAITING, GOT_TYPE, GOT_LENGTH, DONE}; enum TYPE { MSG = 1, ASK, ANS, SYNC, ASYNC, OK }; STATE State; bool BufferedMessages; IvlMsgBuffer Buffered; bool WaitingReply; int InLength; byte InType; IvlMessage* Process (IvlMsgBuffer&, bool); IvlMsgStream (const IvlMsgStream&); void WriteMsg (IvlMessage&); bool ReadMsg (IvlMessage&); public: IvlMsgStream (IvlAddress* = 0, IvlAddress* = 0); ~IvlMsgStream (); void HandleRead (); virtual IvlMessage* DecodeMessage (IvlMsgBuffer&); virtual IvlMessage* DecodeAnswer (IvlMsgBuffer&); void Send (IvlMessage&, bool = false); IvlMessage* Ask (IvlMessage&); void Reply (IvlMessage&); void Send (IvlMsgBuffer&, bool = false); }; #endif /* MsgStream_H_ */