Fixed closed callback

This commit is contained in:
Paul-Louis Ageneau
2020-06-01 11:13:13 +02:00
parent 17f99252cd
commit 9425641f54
3 changed files with 17 additions and 7 deletions

View File

@ -32,9 +32,9 @@ using namespace std;
template <class T> weak_ptr<T> make_weak_ptr(shared_ptr<T> ptr) { return ptr; }
void test_websocket() {
InitLogger(LogLevel::Verbose);
InitLogger(LogLevel::Debug);
const string myMessage = "Hello world";
const string myMessage = "Hello world from libdatachannel";
auto ws = std::make_shared<WebSocket>();
@ -46,6 +46,8 @@ void test_websocket() {
ws->send(myMessage);
});
ws->onClosed([]() { cout << "WebSocket: Closed" << endl; });
std::atomic<bool> received = false;
ws->onMessage([&received, &myMessage](const variant<binary, string> &message) {
if (holds_alternative<string>(message)) {