From 638ef8c73155398c5b2e985c53636be37a7b7155 Mon Sep 17 00:00:00 2001 From: Johnny Date: Wed, 13 Oct 2021 18:41:17 +0800 Subject: [PATCH] =?UTF-8?q?Refine:=20=E8=B0=83=E6=95=B4=20WebRtcSession::g?= =?UTF-8?q?etPoller=20=E9=9D=99=E6=80=81=E5=87=BD=E6=95=B0=E4=B8=BA=20Quer?= =?UTF-8?q?yPollerByBuffer=20=E5=85=A8=E5=B1=80=E5=87=BD=E6=95=B0=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E6=94=B9=E5=96=84=E5=85=B6=E4=BB=96=20getPoller=20?= =?UTF-8?q?=E5=90=8C=E5=90=8D=E5=87=BD=E6=95=B0=E5=8F=AF=E8=AF=BB=E6=80=A7?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/main.cpp | 2 +- webrtc/WebRtcSession.cpp | 4 ++-- webrtc/WebRtcSession.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/server/main.cpp b/server/main.cpp index 0a1110ea..1e333e62 100644 --- a/server/main.cpp +++ b/server/main.cpp @@ -274,7 +274,7 @@ int start_main(int argc,char *argv[]) { if (!buf) { return Socket::createSocket(poller, false); } - auto new_poller = WebRtcSession::getPoller(buf); + auto new_poller = QueryPollerByBuffer(buf); if (!new_poller) { //该数据对应的webrtc对象未找到,丢弃之 return Socket::Ptr(); diff --git a/webrtc/WebRtcSession.cpp b/webrtc/WebRtcSession.cpp index 859aba65..e2295c9e 100644 --- a/webrtc/WebRtcSession.cpp +++ b/webrtc/WebRtcSession.cpp @@ -40,7 +40,7 @@ static string getUserName(const Buffer::Ptr &buffer) { return vec[0]; } -EventPoller::Ptr WebRtcSession::getPoller(const Buffer::Ptr &buffer) { +EventPoller::Ptr QueryPollerByBuffer(const Buffer::Ptr &buffer) { auto user_name = getUserName(buffer); if (user_name.empty()) { return nullptr; @@ -80,7 +80,7 @@ void WebRtcSession::onError(const SockException &err) { return; } auto transport = std::move(_transport); - this->Session::getPoller()->async([transport] { + getPoller()->async([transport] { //延时减引用,防止使用transport对象时,销毁对象 }, false); } diff --git a/webrtc/WebRtcSession.h b/webrtc/WebRtcSession.h index 965f4e6c..3dce62b1 100644 --- a/webrtc/WebRtcSession.h +++ b/webrtc/WebRtcSession.h @@ -18,10 +18,10 @@ using namespace toolkit; +EventPoller::Ptr QueryPollerByBuffer(const Buffer::Ptr &buffer); + class WebRtcSession : public UdpSession { public: - static EventPoller::Ptr getPoller(const Buffer::Ptr &); - WebRtcSession(const Socket::Ptr &sock); ~WebRtcSession() override;