mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-23 07:35:30 +00:00
Fixed state callback and revised synchronization and deletion
This commit is contained in:
@ -108,6 +108,13 @@ void test_connectivity() {
|
||||
|
||||
this_thread::sleep_for(3s);
|
||||
|
||||
if (pc1->state() != PeerConnection::State::Connected &&
|
||||
pc2->state() != PeerConnection::State::Connected)
|
||||
throw runtime_error("PeerConnection is not connected");
|
||||
|
||||
if (!dc1->isOpen() || !dc2->isOpen())
|
||||
throw runtime_error("DataChannel is not open");
|
||||
|
||||
if (auto addr = pc1->localAddress())
|
||||
cout << "Local address 1: " << *addr << endl;
|
||||
if (auto addr = pc1->remoteAddress())
|
||||
@ -117,13 +124,10 @@ void test_connectivity() {
|
||||
if (auto addr = pc2->remoteAddress())
|
||||
cout << "Remote address 2: " << *addr << endl;
|
||||
|
||||
if (!dc1->isOpen() || !dc2->isOpen())
|
||||
throw runtime_error("DataChannel is not open");
|
||||
|
||||
// Delay close of peer 2 to check closing works properly
|
||||
pc1->close();
|
||||
pc2->close();
|
||||
|
||||
this_thread::sleep_for(1s);
|
||||
pc2->close();
|
||||
|
||||
cout << "Success" << endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user