mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-22 23:25:33 +00:00
Some cleanup
This commit is contained in:
@ -36,7 +36,6 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
|
|
||||||
|
|
||||||
using namespace rtc;
|
using namespace rtc;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
@ -167,12 +166,12 @@ int main(int argc, char **argv) try {
|
|||||||
|
|
||||||
dc->onClosed([id]() { cout << "DataChannel from " << id << " closed" << endl; });
|
dc->onClosed([id]() { cout << "DataChannel from " << id << " closed" << endl; });
|
||||||
|
|
||||||
dc->onMessage([id, wdc = make_weak_ptr(dc)](const variant<binary, string> &message) {
|
dc->onMessage([id, wdc = make_weak_ptr(dc)](variant<binary, string> data) {
|
||||||
if (holds_alternative<string>(message))
|
if (holds_alternative<string>(data))
|
||||||
cout << "Message from " << id << " received: " << get<string>(message) << endl;
|
cout << "Message from " << id << " received: " << get<string>(data) << endl;
|
||||||
else
|
else
|
||||||
cout << "Binary message from " << id
|
cout << "Binary message from " << id
|
||||||
<< " received, size=" << get<binary>(message).size() << endl;
|
<< " received, size=" << get<binary>(data).size() << endl;
|
||||||
});
|
});
|
||||||
|
|
||||||
dataChannelMap.emplace(id, dc);
|
dataChannelMap.emplace(id, dc);
|
||||||
@ -225,12 +224,12 @@ shared_ptr<PeerConnection> createPeerConnection(const Configuration &config,
|
|||||||
|
|
||||||
dc->onClosed([id]() { cout << "DataChannel from " << id << " closed" << endl; });
|
dc->onClosed([id]() { cout << "DataChannel from " << id << " closed" << endl; });
|
||||||
|
|
||||||
dc->onMessage([id, wdc = make_weak_ptr(dc)](const variant<binary, string> &message) {
|
dc->onMessage([id, wdc = make_weak_ptr(dc)](variant<binary, string> data) {
|
||||||
if (holds_alternative<string>(message))
|
if (holds_alternative<string>(data))
|
||||||
cout << "Message from " << id << " received: " << get<string>(message) << endl;
|
cout << "Message from " << id << " received: " << get<string>(data) << endl;
|
||||||
else
|
else
|
||||||
cout << "Binary message from " << id
|
cout << "Binary message from " << id
|
||||||
<< " received, size=" << get<binary>(message).size() << endl;
|
<< " received, size=" << get<binary>(data).size() << endl;
|
||||||
});
|
});
|
||||||
|
|
||||||
dc->send("Hello from " + localId);
|
dc->send("Hello from " + localId);
|
||||||
|
@ -227,12 +227,6 @@ int test_capi_connectivity_main() {
|
|||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (peer1->signalingState != RTC_SIGNALING_STABLE ||
|
|
||||||
peer2->signalingState != RTC_SIGNALING_STABLE) {
|
|
||||||
fprintf(stderr, "Signaling state is not stable\n");
|
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!peer1->connected || !peer2->connected) {
|
if (!peer1->connected || !peer2->connected) {
|
||||||
fprintf(stderr, "DataChannel is not connected\n");
|
fprintf(stderr, "DataChannel is not connected\n");
|
||||||
goto error;
|
goto error;
|
||||||
|
Reference in New Issue
Block a user