Skip to content

Commit

Permalink
ConnectedURL と ContactURL を追加
Browse files Browse the repository at this point in the history
  • Loading branch information
melpon committed Sep 2, 2023
1 parent 87c29c8 commit c5095ba
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@

## develop

- [CHANGE] `SoraSignaling::GetConnectedSignalingURL()``SoraSignaling::GetConnectedURL()` にリネーム
- @melpon
- [UPDATE] WebRTC を m116.5845.6.1 に上げる
- @torikizi
- [UPDATE] m116 で `cricket::Codec` は protected になったため `cricket::CreateVideoCodec` を利用するように修正
- @torikizi
- [ADD] `SoraSignaling::GetContactURL()` 関数を追加
- @melpon

## 2023.10.0 (2023-08-26)

Expand Down
19 changes: 17 additions & 2 deletions include/sora/sora_signaling.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@ class SoraSignaling : public std::enable_shared_from_this<SoraSignaling>,
bool SendDataChannel(const std::string& label, const std::string& data);

std::string GetConnectionID() const;
std::string GetConnectedSignalingURL() const;
std::string GetConnectedURL() const;
std::string GetContactURL() const;
bool IsConnectedDataChannel() const;
bool IsConnectedWebsocket() const;

Expand Down Expand Up @@ -252,7 +253,21 @@ class SoraSignaling : public std::enable_shared_from_this<SoraSignaling>,

std::string connection_id_;
std::vector<std::shared_ptr<Websocket>> connecting_wss_;
std::string connected_signaling_url_;
struct atomic_string {
std::string load() const {
std::lock_guard<std::mutex> lock(m);
return s;
}
void store(std::string s) {
std::lock_guard<std::mutex> lock(m);
this->s = s;
}
private:
std::string s;
mutable std::mutex m;
};
atomic_string connected_url_;
atomic_string contact_url_;
std::shared_ptr<Websocket> ws_;
std::shared_ptr<DataChannel> dc_;
bool using_datachannel_ = false;
Expand Down
19 changes: 12 additions & 7 deletions src/sora_signaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,11 @@ std::string SoraSignaling::GetAudioMid() const {
std::string SoraSignaling::GetConnectionID() const {
return connection_id_;
}
std::string SoraSignaling::GetConnectedSignalingURL() const {
return connected_signaling_url_;
std::string SoraSignaling::GetConnectedURL() const {
return connected_url_.load();
}
std::string SoraSignaling::GetContactURL() const {
return contact_url_.load();
}
bool SoraSignaling::IsConnectedDataChannel() const {
return dc_ && using_datachannel_;
Expand Down Expand Up @@ -272,8 +275,8 @@ void SoraSignaling::OnRedirect(boost::system::error_code ec,
state_ = State::Connected;
ws_ = ws;
ws_connected_ = true;
connected_signaling_url_ = url;
RTC_LOG(LS_INFO) << "redirected: url=" << url;
connected_url_.store(url);
RTC_LOG(LS_INFO) << "Redirected: url=" << url;

DoRead();
DoSendConnect(true);
Expand Down Expand Up @@ -823,8 +826,9 @@ void SoraSignaling::OnConnect(boost::system::error_code ec,
state_ = State::Connected;
ws_ = ws;
ws_connected_ = true;
connected_signaling_url_ = url;
RTC_LOG(LS_INFO) << "connected: url=" << url;
contact_url_.store(url);
connected_url_.store(url);
RTC_LOG(LS_INFO) << "Connected: url=" << url;

DoRead();
DoSendConnect(false);
Expand Down Expand Up @@ -1399,7 +1403,8 @@ void SoraSignaling::Clear() {
connection_timeout_timer_.cancel(tec);
closing_timeout_timer_.cancel(tec);
connecting_wss_.clear();
connected_signaling_url_.clear();
connected_url_.store("");
contact_url_.store("");
pc_ = nullptr;
ws_connected_ = false;
ws_ = nullptr;
Expand Down

0 comments on commit c5095ba

Please sign in to comment.