mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-23 15:48:03 +00:00
Fixed call to usrsctp_finish() in Cleanup()
This commit is contained in:
@ -114,6 +114,9 @@ int rtcGetAvailableAmount(int dc); // total size available to receive
|
|||||||
int rtcSetAvailableCallback(int dc, availableCallbackFunc cb);
|
int rtcSetAvailableCallback(int dc, availableCallbackFunc cb);
|
||||||
int rtcReceiveMessage(int dc, char *buffer, int *size);
|
int rtcReceiveMessage(int dc, char *buffer, int *size);
|
||||||
|
|
||||||
|
// Cleanup
|
||||||
|
void rtcCleanup();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
#endif
|
#endif
|
||||||
|
@ -450,3 +450,5 @@ int rtcReceiveMessage(int dc, char *buffer, int *size) {
|
|||||||
*message);
|
*message);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void rtcCleanup() { rtc::Cleanup(); }
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <thread>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifdef USE_JUICE
|
#ifdef USE_JUICE
|
||||||
@ -62,7 +63,10 @@ void SctpTransport::Init() {
|
|||||||
usrsctp_sysctl_set_sctp_heartbeat_interval_default(10 * 1000); // ms
|
usrsctp_sysctl_set_sctp_heartbeat_interval_default(10 * 1000); // ms
|
||||||
}
|
}
|
||||||
|
|
||||||
void SctpTransport::Cleanup() { usrsctp_finish(); }
|
void SctpTransport::Cleanup() {
|
||||||
|
while (usrsctp_finish() != 0)
|
||||||
|
std::this_thread::sleep_for(100ms);
|
||||||
|
}
|
||||||
|
|
||||||
SctpTransport::SctpTransport(std::shared_ptr<Transport> lower, uint16_t port,
|
SctpTransport::SctpTransport(std::shared_ptr<Transport> lower, uint16_t port,
|
||||||
message_callback recvCallback, amount_callback bufferedAmountCallback,
|
message_callback recvCallback, amount_callback bufferedAmountCallback,
|
||||||
|
@ -23,7 +23,12 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
#include <windows.h>
|
||||||
|
static void sleep(unsigned int secs) { Sleep(secs * 1000); }
|
||||||
|
#else
|
||||||
#include <unistd.h> // for sleep
|
#include <unistd.h> // for sleep
|
||||||
|
#endif
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -196,6 +201,10 @@ int test_capi_main() {
|
|||||||
deletePeer(peer2);
|
deletePeer(peer2);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
|
// You may call rtcCleanup() when finished to free static resources
|
||||||
|
rtcCleanup();
|
||||||
|
sleep(1);
|
||||||
|
|
||||||
printf("Success\n");
|
printf("Success\n");
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -140,5 +140,9 @@ void test_connectivity() {
|
|||||||
pc2->close();
|
pc2->close();
|
||||||
this_thread::sleep_for(1s);
|
this_thread::sleep_for(1s);
|
||||||
|
|
||||||
|
// You may call rtc::Cleanup() when finished to free static resources
|
||||||
|
rtc::Cleanup();
|
||||||
|
this_thread::sleep_for(1s);
|
||||||
|
|
||||||
cout << "Success" << endl;
|
cout << "Success" << endl;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user