Skip to content

Commit

Permalink
on_ws_close コールバックを追加する
Browse files Browse the repository at this point in the history
  • Loading branch information
tnoho committed Sep 25, 2024
1 parent a863185 commit 3fae964
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
- @tnoho
- [ADD] Ubuntu 24.04 armv8 に対応する
- @melpon
- [ADD] `on_ws_close` コールバックを追加する
- @tnoho
- [UPDATE] Sora C++ SDK のバージョンを `2024.8.0` に上げる
- WEBRTC_BUILD_VERSION を `m128.6613.2.0` に上げる
- libwebrtc のモジュール分割に追従するため rtc::CreateRandomString のヘッダを追加
Expand Down
6 changes: 6 additions & 0 deletions src/sora_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,12 @@ void SoraConnection::OnSignalingMessage(sora::SoraSignalingType type,
}
}

void SoraConnection::OnWsClose(uint16_t code, std::string message) {
if (on_ws_close_) {
on_ws_close_(code, message);
}
}

void SoraConnection::OnTrack(
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) {
if (on_track_) {
Expand Down
2 changes: 2 additions & 0 deletions src/sora_connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class SoraConnection : public sora::SoraSignalingObserver,
void OnSignalingMessage(sora::SoraSignalingType type,
sora::SoraSignalingDirection direction,
std::string message) override;
void OnWsClose(uint16_t code, std::string message);
void OnTrack(
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) override;
void OnRemoveTrack(
Expand All @@ -116,6 +117,7 @@ class SoraConnection : public sora::SoraSignalingObserver,
void(sora::SoraSignalingType, sora::SoraSignalingDirection, std::string)>
on_signaling_message_;
std::function<void(std::string)> on_set_offer_;
std::function<void(int, std::string)> on_ws_close_;
std::function<void(sora::SoraSignalingErrorCode, std::string)> on_disconnect_;
std::function<void(std::string)> on_notify_;
std::function<void(std::string)> on_push_;
Expand Down
6 changes: 6 additions & 0 deletions src/sora_sdk_ext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ int connection_tp_traverse(PyObject* self, visitproc visit, void* arg) {
Py_VISIT(on_set_offer.ptr());
}

if (conn->on_ws_close_) {
nb::object on_ws_close = nb::cast(conn->on_ws_close_, nb::rv_policy::none);
Py_VISIT(on_ws_close.ptr());
}

if (conn->on_disconnect_) {
nb::object on_disconnect =
nb::cast(conn->on_disconnect_, nb::rv_policy::none);
Expand Down Expand Up @@ -301,6 +306,7 @@ NB_MODULE(sora_sdk_ext, m) {
"data"_a)
.def("get_stats", &SoraConnection::GetStats)
.def_rw("on_set_offer", &SoraConnection::on_set_offer_)
.def_rw("on_ws_close", &SoraConnection::on_ws_close_)
.def_rw("on_disconnect", &SoraConnection::on_disconnect_)
.def_rw("on_signaling_message", &SoraConnection::on_signaling_message_)
.def_rw("on_notify", &SoraConnection::on_notify_)
Expand Down

0 comments on commit 3fae964

Please # to comment.