drogon
drogon copied to clipboard
WebSocketClientImpl::stop also need to run the loop thread
If I call stop on another thread, It will be core dump,because onRecvMessage will use websockConnPtr_
void WebSocketClientImpl::stop()
{
stop_ = true;
if (websockConnPtr_)
{
websockConnPtr_->shutdown();
websockConnPtr_.reset();
}
tcpClientPtr_.reset();
}
tcpClientPtr_->setMessageCallback(
[weakPtr](const trantor::TcpConnectionPtr &connPtr,
trantor::MsgBuffer *msg) {
auto thisPtr = weakPtr.lock();
if (thisPtr)
{
thisPtr->onRecvMessage(connPtr, msg);
}
});