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

View File

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

View File

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

View File

@ -47,17 +47,6 @@ public:
void onClipboardChanged(ClipboardID, const IClipboard*); 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: protected:
enum EResult { kOkay, kUnknown, kDisconnect }; enum EResult { kOkay, kUnknown, kDisconnect };
@ -116,8 +105,6 @@ private:
double m_heartRate; double m_heartRate;
MessageParser m_parser; MessageParser m_parser;
static CEvent::Type s_handshakeCompleteEvent;
}; };
#endif #endif