Stop requiring CConnection::serverInit() to be overridden
Add an explicit callback for subclasses to do their startup in. This
makes it easier to do proper ordering, and avoids mistakes.
diff --git a/common/rfb/CConnection.cxx b/common/rfb/CConnection.cxx
index a503a2c..805c8c3 100644
--- a/common/rfb/CConnection.cxx
+++ b/common/rfb/CConnection.cxx
@@ -335,6 +335,14 @@
CMsgHandler::setExtendedDesktopSize(reason, result, w, h, layout);
}
+void CConnection::serverInit()
+{
+ state_ = RFBSTATE_NORMAL;
+ vlog.debug("initialisation done");
+
+ initDone();
+}
+
void CConnection::readAndDecodeRect(const Rect& r, int encoding,
ModifiablePixelBuffer* pb)
{
@@ -363,10 +371,8 @@
{
}
-void CConnection::serverInit()
+void CConnection::initDone()
{
- state_ = RFBSTATE_NORMAL;
- vlog.debug("initialisation done");
}
void CConnection::fence(rdr::U32 flags, unsigned len, const char data[])
diff --git a/common/rfb/CConnection.h b/common/rfb/CConnection.h
index 1e66a64..c996ecf 100644
--- a/common/rfb/CConnection.h
+++ b/common/rfb/CConnection.h
@@ -100,6 +100,8 @@
int w, int h,
const ScreenSet& layout);
+ virtual void serverInit();
+
virtual void readAndDecodeRect(const Rect& r, int encoding,
ModifiablePixelBuffer* pb);
@@ -113,9 +115,11 @@
// authSuccess() is called when authentication has succeeded.
virtual void authSuccess();
- // serverInit() is called when the ServerInit message is received. The
- // derived class must call on to CConnection::serverInit().
- virtual void serverInit();
+ // initDone() is called when the connection is fully established
+ // and standard messages can be sent. This is called before the
+ // initial FramebufferUpdateRequest giving a derived class the
+ // chance to modify pixel format and settings.
+ virtual void initDone();
// Other methods