diff options
author | Pierre Ossman <ossman@cendio.se> | 2020-05-14 18:49:39 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2020-05-21 12:59:02 +0200 |
commit | ad0f0618fa2ca13d7b916f22eccc5ba3201482cb (patch) | |
tree | 55b84c52f8ab0e7ebe672458471e4577afddc1b9 /common/rfb/SMsgReader.h | |
parent | c0dac220de0186a879f1f71966a2848000f69a48 (diff) | |
download | tigervnc-ad0f0618fa2ca13d7b916f22eccc5ba3201482cb.tar.gz tigervnc-ad0f0618fa2ca13d7b916f22eccc5ba3201482cb.zip |
Change streams to be asynchronous
Major restructuring of how streams work. Neither input nor output
streams are now blocking. This avoids stalling the rest of the client or
server when a peer is slow or unresponsive.
Note that this puts an extra burden on users of streams to make sure
they are allowed to do their work once the underlying transports are
ready (e.g. monitoring fds).
Diffstat (limited to 'common/rfb/SMsgReader.h')
-rw-r--r-- | common/rfb/SMsgReader.h | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/common/rfb/SMsgReader.h b/common/rfb/SMsgReader.h index 4991fd38..acc872ed 100644 --- a/common/rfb/SMsgReader.h +++ b/common/rfb/SMsgReader.h @@ -34,33 +34,43 @@ namespace rfb { SMsgReader(SMsgHandler* handler, rdr::InStream* is); virtual ~SMsgReader(); - void readClientInit(); + bool readClientInit(); // readMsg() reads a message, calling the handler as appropriate. - void readMsg(); + bool readMsg(); rdr::InStream* getInStream() { return is; } protected: - void readSetPixelFormat(); - void readSetEncodings(); - void readSetDesktopSize(); + bool readSetPixelFormat(); + bool readSetEncodings(); + bool readSetDesktopSize(); - void readFramebufferUpdateRequest(); - void readEnableContinuousUpdates(); + bool readFramebufferUpdateRequest(); + bool readEnableContinuousUpdates(); - void readFence(); + bool readFence(); - void readKeyEvent(); - void readPointerEvent(); - void readClientCutText(); - void readExtendedClipboard(rdr::S32 len); + bool readKeyEvent(); + bool readPointerEvent(); + bool readClientCutText(); + bool readExtendedClipboard(rdr::S32 len); - void readQEMUMessage(); - void readQEMUKeyEvent(); + bool readQEMUMessage(); + bool readQEMUKeyEvent(); + private: SMsgHandler* handler; rdr::InStream* is; + + enum stateEnum { + MSGSTATE_IDLE, + MSGSTATE_MESSAGE, + }; + + stateEnum state; + + rdr::U8 currentMsgType; }; } #endif |