void onClientStateChange(void* sender, sockio::ClientState& state, const sockio::ClientState& oldState) { auto client = reinterpret_cast<sockio::Client*>(sender); DebugL << "Connection state changed: " << state.toString() << endl; switch (state.id()) { case sockio::ClientState::Connecting: break; case sockio::ClientState::Connected: DebugL << "Connected" << endl; break; case sockio::ClientState::Online: // TODO: Send message client->send("ping", "hello", true); break; case sockio::ClientState::Error: break; } }
void onClientStateChange(void* sender, sockio::ClientState& state, const sockio::ClientState& oldState) { smpl::Client* client = reinterpret_cast<smpl::Client*>(sender); DebugL << "Client state changed: " << state << ": " << client->ws().socket->address() << endl; switch (state.id()) { case sockio::ClientState::Connecting: break; case sockio::ClientState::Connected: break; case sockio::ClientState::Online: break; case sockio::ClientState::Error: assert(0); break; } }
void onClientStateChange(void* sender, sockio::ClientState& state, const sockio::ClientState& oldState) { smpl::Client* client = reinterpret_cast<smpl::Client*>(sender); DebugL << "Client state changed: " << state << ": " << client->ws().socket->address() << endl; switch (state.id()) { case sockio::ClientState::Connecting: break; case sockio::ClientState::Connected: break; case sockio::ClientState::Online: { // Send a message when online smpl::Message m; m.setData("olay"); client->send(m, true); } break; case sockio::ClientState::Error: assert(0); break; } }