Ejemplo n.º 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();
}
Ejemplo n.º 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--;
}
Ejemplo n.º 3
0
void MainWindow::processServerShutdownEvent(const Event_ServerShutdown &event)
{
    QMessageBox::information(this, tr("Scheduled server shutdown"), tr("The server is going to be restarted in %n minute(s).\nAll running games will be lost.\nReason for shutdown: %1", "", event.minutes()).arg(QString::fromStdString(event.reason())));
}
Ejemplo n.º 4
0
void MainWindow::processServerShutdownEvent(const Event_ServerShutdown &event)
{
    serverShutdownMessageBox.setInformativeText(tr("The server is going to be restarted in %n minute(s).\nAll running games will be lost.\nReason for shutdown: %1", "", event.minutes()).arg(QString::fromStdString(event.reason())));
    serverShutdownMessageBox.setIconPixmap(QPixmap(":/resources/appicon.svg").scaled(64, 64));
    serverShutdownMessageBox.setText(tr("Scheduled server shutdown"));
    serverShutdownMessageBox.setWindowModality(Qt::ApplicationModal);
    serverShutdownMessageBox.setVisible(true);
}