Fixed handling of handshake complete. Was posting an event for it

but making direct calls for other messages from the server.  This
could cause messages to be handled out of order.  Now making a
direct call for handshake complete.
This commit is contained in:
crs 2004-03-13 17:16:24 +00:00
parent 8c1af9d53f
commit 12fa99aee0
4 changed files with 16 additions and 44 deletions

View File

@ -111,6 +111,14 @@ CClient::disconnect(const char* msg)
}
}
void
CClient::handshakeComplete()
{
m_ready = true;
m_screen->enable();
sendEvent(getConnectedEvent(), NULL);
}
bool
CClient::isConnected() const
{
@ -386,10 +394,6 @@ CClient::setupScreen()
getEventTarget(),
new TMethodEventJob<CClient>(this,
&CClient::handleClipboardGrabbed));
EVENTQUEUE->adoptHandler(CServerProxy::getHandshakeCompleteEvent(),
m_server,
new TMethodEventJob<CClient>(this,
&CClient::handleHandshakeComplete));
}
void
@ -437,11 +441,7 @@ void
CClient::cleanupScreen()
{
if (m_server != NULL) {
if (!m_ready) {
EVENTQUEUE->removeHandler(CServerProxy::getHandshakeCompleteEvent(),
m_server);
}
else {
if (m_ready) {
m_screen->disable();
m_ready = false;
}
@ -523,16 +523,6 @@ CClient::handleDisconnected(const CEvent&, void*)
sendEvent(getDisconnectedEvent(), NULL);
}
void
CClient::handleHandshakeComplete(const CEvent&, void*)
{
m_ready = true;
EVENTQUEUE->removeHandler(CServerProxy::getHandshakeCompleteEvent(),
m_server);
sendEvent(getConnectedEvent(), NULL);
m_screen->enable();
}
void
CClient::handleShapeChanged(const CEvent&, void*)
{

View File

@ -66,6 +66,12 @@ public:
*/
void disconnect(const char* msg);
//! Notify of handshake complete
/*!
Notifies the client that the connection handshake has completed.
*/
void handshakeComplete();
//@}
//! @name accessors
//@{
@ -152,7 +158,6 @@ private:
void handleConnectTimeout(const CEvent&, void*);
void handleOutputError(const CEvent&, void*);
void handleDisconnected(const CEvent&, void*);
void handleHandshakeComplete(const CEvent&, void*);
void handleShapeChanged(const CEvent&, void*);
void handleClipboardGrabbed(const CEvent&, void*);
void handleHello(const CEvent&, void*);

View File

@ -29,9 +29,6 @@
// CServerProxy
//
CEvent::Type CServerProxy::s_handshakeCompleteEvent =
CEvent::kUnknown;
CServerProxy::CServerProxy(CClient* client, IStream* stream) :
m_client(client),
m_stream(stream),
@ -66,13 +63,6 @@ CServerProxy::~CServerProxy()
m_stream->getEventTarget());
}
CEvent::Type
CServerProxy::getHandshakeCompleteEvent()
{
return CEvent::registerTypeOnce(s_handshakeCompleteEvent,
"CServerProxy::handshakeComplete");
}
void
CServerProxy::installHeartBeat(double heartRate)
{
@ -141,7 +131,7 @@ CServerProxy::parseHandshakeMessage(const UInt8* code)
// handshake is complete
m_parser = &CServerProxy::parseMessage;
EVENTQUEUE->addEvent(CEvent(getHandshakeCompleteEvent(), this));
m_client->handshakeComplete();
}
else if (memcmp(code, kMsgCResetOptions, 4) == 0) {

View File

@ -47,17 +47,6 @@ public:
void onClipboardChanged(ClipboardID, const IClipboard*);
//@}
//! @name accessors
//@{
//! Get handshake complete event type
/*!
Returns the handshake complete event type. This is sent when the
client has completed the handshake with the server.
*/
static CEvent::Type getHandshakeCompleteEvent();
//@}
protected:
enum EResult { kOkay, kUnknown, kDisconnect };
@ -116,8 +105,6 @@ private:
double m_heartRate;
MessageParser m_parser;
static CEvent::Type s_handshakeCompleteEvent;
};
#endif