CConnection::~CConnection()
{
- setFramebuffer(NULL);
- if (csecurity)
- delete csecurity;
- delete reader_;
- reader_ = 0;
- delete writer_;
- writer_ = 0;
- strFree(serverClipboard);
+ close();
}
void CConnection::setStreams(rdr::InStream* is_, rdr::OutStream* os_)
writer_->writeClientInit(shared);
}
+void CConnection::close()
+{
+ state_ = RFBSTATE_CLOSING;
+
+ setFramebuffer(NULL);
+ delete csecurity;
+ csecurity = NULL;
+ delete reader_;
+ reader_ = NULL;
+ delete writer_;
+ writer_ = NULL;
+ strFree(serverClipboard);
+ serverClipboard = NULL;
+}
+
void CConnection::setDesktopSize(int w, int h)
{
decoder.flush();
// NB: In either case, you must have called initialiseProtocol() first.
void processMsg();
+ // close() gracefully shuts down the connection to the server and
+ // should be called before terminating the underlying network
+ // connection
+ void close();
+
// Methods overridden from CMsgHandler
RFBSTATE_SECURITY_RESULT,
RFBSTATE_INITIALISATION,
RFBSTATE_NORMAL,
+ RFBSTATE_CLOSING,
RFBSTATE_INVALID
};
SConnection::~SConnection()
{
- if (ssecurity)
- delete ssecurity;
- delete reader_;
- reader_ = 0;
- delete writer_;
- writer_ = 0;
- strFree(clientClipboard);
+ cleanup();
}
void SConnection::setStreams(rdr::InStream* is_, rdr::OutStream* os_)
void SConnection::close(const char* reason)
{
state_ = RFBSTATE_CLOSING;
+ cleanup();
}
void SConnection::setPixelFormat(const PixelFormat& pf)
}
}
+void SConnection::cleanup()
+{
+ delete ssecurity;
+ ssecurity = NULL;
+ delete reader_;
+ reader_ = NULL;
+ delete writer_;
+ writer_ = NULL;
+ strFree(clientClipboard);
+ clientClipboard = NULL;
+}
+
void SConnection::writeFakeColourMap(void)
{
int i;
void setWriter(SMsgWriter *w) { writer_ = w; }
private:
+ void cleanup();
void writeFakeColourMap(void);
bool readyForSetColourMapEntries;
void VNCSConnectionST::close(const char* reason)
{
+ SConnection::close(reason);
+
// Log the reason for the close
if (!closeReason.buf)
closeReason.buf = strDup(reason);
// calling code will call VNCServerST's removeSocket() method causing us to
// be deleted.
sock->shutdown();
-
- SConnection::close(reason);
}
CConn::~CConn()
{
+ close();
+
OptionsDialog::removeCallback(handleOptions);
Fl::remove_timeout(handleUpdateTimeout, this);