Dispatch sends and pings to the websocket strand.

This commit is contained in:
JoelKatz
2013-05-08 10:52:21 -07:00
parent 2b6a91143b
commit c31a8e7794
2 changed files with 22 additions and 5 deletions

View File

@@ -101,6 +101,7 @@ public:
if (theApp->getLoadManager().shouldCutoff(mLoadSource))
{
#if SHOULD_DISCONNECT
// FIXME: Must dispatch to strand
connection_ptr ptr = mConnection.lock();
if (ptr)
ptr->close(websocketpp::close::status::PROTOCOL_ERROR, "overload");
@@ -199,9 +200,13 @@ public:
void setPingTimer()
{
mPingTimer.expires_from_now(boost::posix_time::seconds(WEBSOCKET_PING_FREQUENCY));
mPingTimer.async_wait(boost::bind(
&WSConnection<endpoint_type>::pingTimer, mConnection, mHandler, boost::asio::placeholders::error));
connection_ptr ptr = mConnection.lock();
if (ptr)
{
mPingTimer.expires_from_now(boost::posix_time::seconds(WEBSOCKET_PING_FREQUENCY));
mPingTimer.async_wait(ptr->get_strand().wrap(boost::bind(
&WSConnection<endpoint_type>::pingTimer, mConnection, mHandler, boost::asio::placeholders::error)));
}
}
void rcvMessage(message_ptr msg, bool& msgRejected, bool& runQueue)