mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 12:45:35 +08:00
Set data receive interface for test
This commit is contained in:
@@ -9,7 +9,8 @@
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
PeerConnection::PeerConnection() {}
|
||||
PeerConnection::PeerConnection(OnReceiveBuffer on_receive_buffer)
|
||||
: on_receive_buffer_(on_receive_buffer) {}
|
||||
|
||||
PeerConnection::~PeerConnection() {}
|
||||
|
||||
@@ -36,9 +37,9 @@ int PeerConnection::Init(PeerConnectionParams params,
|
||||
|
||||
on_receive_ws_msg_ = [this](const std::string &msg) { ProcessSignal(msg); };
|
||||
|
||||
on_receive_ice_msg_ = [this](const char *data, size_t size) {
|
||||
std::string msg(data, size);
|
||||
LOG_INFO("Receive data: [{}]", msg.c_str());
|
||||
on_receive_ice_msg_ = [this](const char *data, size_t size,
|
||||
const char *user_id, size_t user_id_size) {
|
||||
on_receive_buffer_(data, size, user_id, user_id_size);
|
||||
};
|
||||
|
||||
ws_transport_ = new WsTransmission(on_receive_ws_msg_);
|
||||
@@ -187,7 +188,6 @@ void PeerConnection::ProcessSignal(const std::string &signal) {
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
// ice_transmission_->OnReceiveMessage(msg);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
enum SignalStatus { Connecting = 0, Connected, Closed };
|
||||
|
||||
typedef void (*OnReceiveBuffer)(unsigned char *, size_t, const char *,
|
||||
typedef void (*OnReceiveBuffer)(const char *, size_t, const char *,
|
||||
const size_t);
|
||||
|
||||
typedef void (*NetStatusReport)(const unsigned short, const unsigned short);
|
||||
@@ -22,7 +22,7 @@ typedef struct {
|
||||
|
||||
class PeerConnection {
|
||||
public:
|
||||
PeerConnection();
|
||||
PeerConnection(OnReceiveBuffer on_receive_buffer);
|
||||
~PeerConnection();
|
||||
|
||||
public:
|
||||
@@ -59,12 +59,15 @@ class PeerConnection {
|
||||
IceTransmission *ice_transmission_ = nullptr;
|
||||
std::map<std::string, IceTransmission *> ice_transmission_list_;
|
||||
std::function<void(const std::string &)> on_receive_ws_msg_ = nullptr;
|
||||
std::function<void(const char *, size_t)> on_receive_ice_msg_ = nullptr;
|
||||
std::function<void(const char *, size_t, const char *, size_t)>
|
||||
on_receive_ice_msg_ = nullptr;
|
||||
unsigned int ws_connection_id_ = 0;
|
||||
std::string user_id_ = "";
|
||||
std::string transmission_id_ = "";
|
||||
std::vector<std::string> user_id_list_;
|
||||
SignalStatus signal_status_ = SignalStatus::Closed;
|
||||
|
||||
OnReceiveBuffer on_receive_buffer_;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user