mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-26 20:25:34 +08:00
47 lines
1.2 KiB
C++
47 lines
1.2 KiB
C++
#ifndef _PEER_CONNECTION_H_
|
|
#define _PEER_CONNECTION_H_
|
|
|
|
#include <iostream>
|
|
|
|
#include "ice_transport.h"
|
|
#include "ws_transport.h"
|
|
|
|
enum SignalStatus { Connecting = 0, Connected, Closed };
|
|
|
|
typedef void (*OnReceiveBuffer)(unsigned char *, size_t, const char *,
|
|
const size_t);
|
|
|
|
typedef void (*NetStatusReport)(const unsigned short, const unsigned short);
|
|
|
|
typedef struct {
|
|
const char *cfg_path;
|
|
OnReceiveBuffer on_receive_buffer;
|
|
NetStatusReport net_status_report;
|
|
} PeerConnectionParams;
|
|
|
|
class PeerConnection {
|
|
public:
|
|
PeerConnection();
|
|
~PeerConnection();
|
|
|
|
public:
|
|
int Init(PeerConnectionParams params);
|
|
int Init(PeerConnectionParams params, std::string const &id);
|
|
int Destroy();
|
|
|
|
SignalStatus GetSignalStatus();
|
|
|
|
int SendData(const char *data, size_t size);
|
|
|
|
private:
|
|
std::string uri_ = "";
|
|
WsTransport *ws_transport_ = nullptr;
|
|
IceTransport *ice_transport_ = nullptr;
|
|
std::function<void(const std::string &)> on_receive_ws_msg_ = nullptr;
|
|
std::function<void(const char *, size_t)> on_receive_ice_msg_ = nullptr;
|
|
unsigned int ws_connection_id_ = 0;
|
|
std::string transport_id_ = "";
|
|
SignalStatus signal_status_ = SignalStatus::Closed;
|
|
};
|
|
|
|
#endif |