Remove usage of rtc::MessageHandler in peer_connection example
Bug: webrtc:9702 Change-Id: I2d688461858d9b6f06a0f7928f3cff7c6a7b7db9 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/272080 Auto-Submit: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/main@{#37813}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
85b40f0021
commit
b9201b0ef4
@ -693,6 +693,8 @@ if (is_linux || is_chromeos || is_win) {
|
|||||||
"../api:scoped_refptr",
|
"../api:scoped_refptr",
|
||||||
"../api/audio:audio_mixer_api",
|
"../api/audio:audio_mixer_api",
|
||||||
"../api/audio_codecs:audio_codecs_api",
|
"../api/audio_codecs:audio_codecs_api",
|
||||||
|
"../api/task_queue:pending_task_safety_flag",
|
||||||
|
"../api/units:time_delta",
|
||||||
"../api/video:video_frame",
|
"../api/video:video_frame",
|
||||||
"../api/video:video_rtp_headers",
|
"../api/video:video_rtp_headers",
|
||||||
"../api/video_codecs:video_codecs_api",
|
"../api/video_codecs:video_codecs_api",
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
#include "examples/peerconnection/client/peer_connection_client.h"
|
#include "examples/peerconnection/client/peer_connection_client.h"
|
||||||
|
|
||||||
|
#include "api/units/time_delta.h"
|
||||||
#include "examples/peerconnection/client/defaults.h"
|
#include "examples/peerconnection/client/defaults.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
@ -18,9 +19,9 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
// This is our magical hangup signal.
|
// This is our magical hangup signal.
|
||||||
const char kByeMessage[] = "BYE";
|
constexpr char kByeMessage[] = "BYE";
|
||||||
// Delay between server connection retries, in milliseconds
|
// Delay between server connection retries, in milliseconds
|
||||||
const int kReconnectDelay = 2000;
|
constexpr webrtc::TimeDelta kReconnectDelay = webrtc::TimeDelta::Seconds(2);
|
||||||
|
|
||||||
rtc::Socket* CreateClientSocket(int family) {
|
rtc::Socket* CreateClientSocket(int family) {
|
||||||
rtc::Thread* thread = rtc::Thread::Current();
|
rtc::Thread* thread = rtc::Thread::Current();
|
||||||
@ -33,9 +34,7 @@ rtc::Socket* CreateClientSocket(int family) {
|
|||||||
PeerConnectionClient::PeerConnectionClient()
|
PeerConnectionClient::PeerConnectionClient()
|
||||||
: callback_(NULL), resolver_(NULL), state_(NOT_CONNECTED), my_id_(-1) {}
|
: callback_(NULL), resolver_(NULL), state_(NOT_CONNECTED), my_id_(-1) {}
|
||||||
|
|
||||||
PeerConnectionClient::~PeerConnectionClient() {
|
PeerConnectionClient::~PeerConnectionClient() = default;
|
||||||
rtc::Thread::Current()->Clear(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerConnectionClient::InitSocketSignals() {
|
void PeerConnectionClient::InitSocketSignals() {
|
||||||
RTC_DCHECK(control_socket_.get() != NULL);
|
RTC_DCHECK(control_socket_.get() != NULL);
|
||||||
@ -480,16 +479,11 @@ void PeerConnectionClient::OnClose(rtc::Socket* socket, int err) {
|
|||||||
} else {
|
} else {
|
||||||
if (socket == control_socket_.get()) {
|
if (socket == control_socket_.get()) {
|
||||||
RTC_LOG(LS_WARNING) << "Connection refused; retrying in 2 seconds";
|
RTC_LOG(LS_WARNING) << "Connection refused; retrying in 2 seconds";
|
||||||
rtc::Thread::Current()->PostDelayed(RTC_FROM_HERE, kReconnectDelay, this,
|
rtc::Thread::Current()->PostDelayedTask(
|
||||||
0);
|
SafeTask(safety_.flag(), [this] { DoConnect(); }), kReconnectDelay);
|
||||||
} else {
|
} else {
|
||||||
Close();
|
Close();
|
||||||
callback_->OnDisconnected();
|
callback_->OnDisconnected();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerConnectionClient::OnMessage(rtc::Message* msg) {
|
|
||||||
// ignore msg; there is currently only one supported message ("retry")
|
|
||||||
DoConnect();
|
|
||||||
}
|
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include "api/task_queue/pending_task_safety_flag.h"
|
||||||
#include "rtc_base/net_helpers.h"
|
#include "rtc_base/net_helpers.h"
|
||||||
#include "rtc_base/physical_socket_server.h"
|
#include "rtc_base/physical_socket_server.h"
|
||||||
#include "rtc_base/third_party/sigslot/sigslot.h"
|
#include "rtc_base/third_party/sigslot/sigslot.h"
|
||||||
@ -34,8 +35,7 @@ struct PeerConnectionClientObserver {
|
|||||||
virtual ~PeerConnectionClientObserver() {}
|
virtual ~PeerConnectionClientObserver() {}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PeerConnectionClient : public sigslot::has_slots<>,
|
class PeerConnectionClient : public sigslot::has_slots<> {
|
||||||
public rtc::MessageHandler {
|
|
||||||
public:
|
public:
|
||||||
enum State {
|
enum State {
|
||||||
NOT_CONNECTED,
|
NOT_CONNECTED,
|
||||||
@ -65,9 +65,6 @@ class PeerConnectionClient : public sigslot::has_slots<>,
|
|||||||
|
|
||||||
bool SignOut();
|
bool SignOut();
|
||||||
|
|
||||||
// implements the MessageHandler interface
|
|
||||||
void OnMessage(rtc::Message* msg);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void DoConnect();
|
void DoConnect();
|
||||||
void Close();
|
void Close();
|
||||||
@ -126,6 +123,7 @@ class PeerConnectionClient : public sigslot::has_slots<>,
|
|||||||
Peers peers_;
|
Peers peers_;
|
||||||
State state_;
|
State state_;
|
||||||
int my_id_;
|
int my_id_;
|
||||||
|
webrtc::ScopedTaskSafety safety_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EXAMPLES_PEERCONNECTION_CLIENT_PEER_CONNECTION_CLIENT_H_
|
#endif // EXAMPLES_PEERCONNECTION_CLIENT_PEER_CONNECTION_CLIENT_H_
|
||||||
|
Reference in New Issue
Block a user