mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Refactor connection create process
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
#include "ws_transport.h"
|
||||
#include "ws_transmission.h"
|
||||
|
||||
#include "log.h"
|
||||
|
||||
WsTransport::WsTransport(
|
||||
WsTransmission::WsTransmission(
|
||||
std::function<void(const std::string &)> on_receive_msg_cb)
|
||||
: on_receive_msg_(on_receive_msg_cb) {}
|
||||
|
||||
WsTransport::~WsTransport() {}
|
||||
WsTransmission::~WsTransmission() {}
|
||||
|
||||
void WsTransport::OnReceiveMessage(const std::string &msg) {
|
||||
void WsTransmission::OnReceiveMessage(const std::string &msg) {
|
||||
LOG_INFO("Receive msg: {}", msg);
|
||||
if (on_receive_msg_) {
|
||||
on_receive_msg_(msg);
|
||||
18
src/ws/ws_transmission.h
Normal file
18
src/ws/ws_transmission.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _WS_TRANSMISSION_H_
|
||||
#define _WS_TRANSMISSION_H_
|
||||
|
||||
#include "ws_core.h"
|
||||
|
||||
class WsTransmission : public WsCore {
|
||||
public:
|
||||
WsTransmission(std::function<void(const std::string &)> on_receive_msg_cb);
|
||||
~WsTransmission();
|
||||
|
||||
public:
|
||||
void OnReceiveMessage(const std::string &msg);
|
||||
|
||||
private:
|
||||
std::function<void(const std::string &)> on_receive_msg_ = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef _WS_TRANSPORT_H_
|
||||
#define _WS_TRANSPORT_H_
|
||||
|
||||
#include "ws_core.h"
|
||||
|
||||
class WsTransport : public WsCore {
|
||||
public:
|
||||
WsTransport(std::function<void(const std::string &)> on_receive_msg_cb);
|
||||
~WsTransport();
|
||||
|
||||
public:
|
||||
void OnReceiveMessage(const std::string &msg);
|
||||
|
||||
private:
|
||||
std::function<void(const std::string &)> on_receive_msg_ = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user