Exemple #1
0
void Servatrice::shutdownTimeout()
{
    --shutdownMinutes;
    
    SessionEvent *se;
    if (shutdownMinutes) {
        Event_ServerShutdown event;
        event.set_reason(shutdownReason.toStdString());
        event.set_minutes(shutdownMinutes);
        se = Server_ProtocolHandler::prepareSessionEvent(event);
    } else {
        Event_ConnectionClosed event;
        event.set_reason(Event_ConnectionClosed::SERVER_SHUTDOWN);
        se = Server_ProtocolHandler::prepareSessionEvent(event);
    }
    
    clientsLock.lockForRead();
    for (int i = 0; i < clients.size(); ++i)
        clients[i]->sendProtocolItem(*se);
    clientsLock.unlock();
    delete se;
    
    if (!shutdownMinutes)
        deleteLater();
}
Exemple #2
0
void Servatrice::shutdownTimeout()
{
    // Show every time counter cut in half & every minute for last 5 minutes
    if (shutdownMinutes <= 5 || shutdownMinutes == nextShutdownMessageMinutes) {
        if (shutdownMinutes == nextShutdownMessageMinutes)
            nextShutdownMessageMinutes = shutdownMinutes / 2;

        SessionEvent *se;
        if (shutdownMinutes) {
            Event_ServerShutdown event;
            event.set_reason(shutdownReason.toStdString());
            event.set_minutes(shutdownMinutes);
            se = Server_ProtocolHandler::prepareSessionEvent(event);
        } else {
            Event_ConnectionClosed event;
            event.set_reason(Event_ConnectionClosed::SERVER_SHUTDOWN);
            se = Server_ProtocolHandler::prepareSessionEvent(event);
        }

        clientsLock.lockForRead();
        for (int i = 0; i < clients.size(); ++i)
            clients[i]->sendProtocolItem(*se);
        clientsLock.unlock();
        delete se;

        if (!shutdownMinutes)
            deleteLater();
    }
    shutdownMinutes--;
}