From 418d2fde0c702a1f117ecfe9a9904ea53bc5f988 Mon Sep 17 00:00:00 2001 From: Joshua Moerman Date: Tue, 2 Apr 2013 21:00:05 +0200 Subject: [PATCH] Better messages --- src/main.cpp | 4 ++++ src/websockets.h | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1f6201b..f6c5ba3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -20,10 +20,12 @@ websockets::TestProtocol default_protocol{ // connection established [](User& user, basic_websocket_info){ app->login(user); + std::cout << "New user!\n"; }, // connection closed [](User& user, basic_websocket_info){ app->logout(user); + std::cout << "User left: " << &user << ": " << user.name << std::endl; }, // write (will always come after receive) [](User& user, basic_websocket_info) -> std::string{ @@ -39,8 +41,10 @@ websockets::TestProtocol default_protocol{ auto command = object["command"]; if(command == "add line"){ app->add_line(from_json(object["data"])); + std::cout << "Line from: " << &user << ": " << user.name << std::endl; } else if (command == "update user") { user = from_json(object["data"]); + std::cout << "Updated user: " << &user << ": " << user.name << std::endl; } } catch(std::exception& e) { throw websockets::runtime_error(e.what()); diff --git a/src/websockets.h b/src/websockets.h index 95c9da9..1882875 100644 --- a/src/websockets.h +++ b/src/websockets.h @@ -124,12 +124,12 @@ namespace websockets { try{ switch (reason) { case LWS_CALLBACK_ESTABLISHED: - lwsl_notice("Connection established (%p, %p)\n", this, user_ptr); + if(verbose) lwsl_notice("Connection established (%p, %p)\n", this, user_ptr); new (user_ptr) user_type(); establish_func(user, binfo); break; case LWS_CALLBACK_CLOSED: - lwsl_notice("Connection closed (%p, %p)\n", this, user_ptr); + if(verbose) lwsl_notice("Connection closed (%p, %p)\n", this, user_ptr); user.~user_type(); close_func(user, binfo); break;