Skip to content

Commit

Permalink
2個目以上の WS 接続で落ちることがあったのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
melpon committed Oct 24, 2024
1 parent 06af5af commit a28da31
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
1 change: 0 additions & 1 deletion include/sora/sora_signaling.h
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,6 @@ class SoraSignaling : public std::enable_shared_from_this<SoraSignaling>,
Connected,
Closing,
Closed,
Destructing,
};

State state_ = State::Init;
Expand Down
9 changes: 3 additions & 6 deletions src/sora_signaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,10 +759,6 @@ void SoraSignaling::OnConnect(boost::system::error_code ec,
[ws](std::shared_ptr<Websocket> p) { return p == ws; }),
connecting_wss_.end());

if (state_ == State::Closed) {
return;
}

if (ec) {
RTC_LOG(LS_WARNING) << "Failed Websocket handshake: " << ec
<< " url=" << url << " state=" << (int)state_
Expand All @@ -779,9 +775,10 @@ void SoraSignaling::OnConnect(boost::system::error_code ec,
return;
}

if (state_ == State::Connected || state_ == State::Redirecting) {
if (state_ == State::Connected || state_ == State::Redirecting ||
state_ == State::Closing || state_ == State::Closed) {
// 既に他の接続が先に完了していたので、切断する
ws->Close([self = shared_from_this(), ws](boost::system::error_code) {},
ws->Close([ws](boost::system::error_code) {},
config_.websocket_close_timeout);
return;
}
Expand Down

0 comments on commit a28da31

Please sign in to comment.