Пример #1
0
    void WSThread_tls::startTimer(websocketpp::connection_hdl hdl)
    {
        if (hdl.expired())
            return;
        
        try {
            bool hasDevice;
            string resp = m_connections[hdl].tangoConnForClient->getJsonForAttribute(hasDevice);
            
            if (hdl.expired())
                return;
            
            send(hdl, resp);

            if (!hasDevice) {
                m_connections[hdl].timing.reset(nullptr);
                return;
            }
            m_connections[hdl].timerInd++;
            m_connections[hdl].timing->m_timer = m_server.set_timer(m_connections[hdl].timing->msec, bind(&WSThread_tls::runTimer
                                                                                                          , this, placeholders::_1, hdl, m_connections[hdl].timerInd));
        }
        catch (...) {
            // This exception is not thrown out in normal operation
            ERROR_STREAM_F << "START EXCEPTION!!!!!!!";
        }
    }
Пример #2
0
    void WSThread_tls::runTimer(const error_code & ec, websocketpp::connection_hdl hdl, int timerInd)
    {
        // Все данные в m_connections[hdl]
        if (hdl.expired())
            return;

        if (m_connections[hdl].timing == nullptr)
            return;
        if (!m_connections[hdl].timing->isTimerOn)
            return;

        if (ec.value() !=0 ) {
            ERROR_STREAM_F << " Error code: " << ec.value() << " Mess: " << ec.message();
        }

        try {
            if (forRunTimer(hdl, timerInd))
                return;
            m_connections[hdl].timing->m_timer = m_server.set_timer(m_connections[hdl].timing->msec, bind(&WSThread_tls::runTimer
                , this, placeholders::_1, hdl, timerInd));
        }
        catch (...) {
            // This exception is not thrown out in normal operation
            ERROR_STREAM_F << "RUN EXCEPTION!!!!!!!";
        }
    }