mirror of
https://github.com/kunkundi/crossdesk.git
synced 2025-10-27 04:35:34 +08:00
Add test interface for ice data transport
This commit is contained in:
@@ -1,44 +1,21 @@
|
||||
#include "rtc.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
#include "ice_agent.h"
|
||||
#include "log.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "peer_connection.h"
|
||||
#include "ws_transport.h"
|
||||
|
||||
using nlohmann::json;
|
||||
|
||||
static const std::vector<std::string> siganl_status = {"Connecting",
|
||||
"Connected", "Closed"};
|
||||
|
||||
class WsSender : public WsCore {
|
||||
public:
|
||||
WsSender() {}
|
||||
~WsSender() {}
|
||||
|
||||
void OnReceiveMessage(const std::string &msg) {
|
||||
LOG_INFO("Receive msg: {}", msg);
|
||||
}
|
||||
};
|
||||
|
||||
static WsSender *ws_client;
|
||||
static PeerConnection *peer_connection;
|
||||
|
||||
int CreatePeerConnection(const char *uri) {
|
||||
peer_connection = new PeerConnection();
|
||||
peer_connection->Init(uri);
|
||||
|
||||
// do {
|
||||
// } while (SignalStatus::Connected != peer_connection->GetSignalStatus());
|
||||
|
||||
// LOG_INFO("Signal status: {}",
|
||||
// siganl_status[peer_connection->GetSignalStatus()]);
|
||||
|
||||
// peer_connection->CreateTransport();
|
||||
// peer_connection->CreateOffer();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -46,56 +23,12 @@ int CreatePeerConnectionWithID(const char *uri, const char *id) {
|
||||
peer_connection = new PeerConnection();
|
||||
peer_connection->Init(uri, id);
|
||||
|
||||
// do {
|
||||
// } while (SignalStatus::Connected != peer_connection->GetSignalStatus());
|
||||
|
||||
// LOG_INFO("Signal status: {}",
|
||||
// siganl_status[peer_connection->GetSignalStatus()]);
|
||||
|
||||
// peer_connection->CreateTransport(id);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtc() {
|
||||
ws_client = new WsSender();
|
||||
int SendData(const char *data, size_t size) {
|
||||
peer_connection->SendData(data, size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CreateWsClient(const char *uri) {
|
||||
ws_client->Connect(uri);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WsSendMsg(const char *message) {
|
||||
ws_client->Send(message);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
// ws_status GetWsStatus()
|
||||
// {
|
||||
// std::string ws_status = ws_client->GetStatus();
|
||||
|
||||
// if ("Connecting" == ws_status)
|
||||
// {
|
||||
// return ws_status::WS_CONNECTING;
|
||||
// }
|
||||
// else if ("Open" == ws_status)
|
||||
// {
|
||||
// return ws_status::WS_OPEN;
|
||||
// }
|
||||
// else if ("Failed" == ws_status)
|
||||
// {
|
||||
// return ws_status::WS_FAILED;
|
||||
// }
|
||||
// else if ("Closed" == ws_status)
|
||||
// {
|
||||
// return ws_status::WS_CLOSED;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return ws_status::WS_UNKNOWN;
|
||||
// }
|
||||
// }
|
||||
int rtc() { return 0; }
|
||||
@@ -11,18 +11,12 @@ int CreatePeerConnection(const char* uri);
|
||||
|
||||
int CreatePeerConnectionWithID(const char* uri, const char* id);
|
||||
|
||||
int SendData(const char* data, size_t size);
|
||||
|
||||
int rtc();
|
||||
|
||||
int ConnectToServer(const char* uri);
|
||||
|
||||
int RegisterPeer();
|
||||
|
||||
int CreateWsClient(const char* uri);
|
||||
|
||||
int WsSendMsg(const char* message);
|
||||
|
||||
ws_status GetWsStatus();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user