示例#1
0
    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;
        }
    }
示例#2
0
    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;
        }
    }
示例#3
0
    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;
        }
    }