Ejemplo n.º 1
0
void connection::onDisconnected()
{
    m_bufferOffset = 0;
    m_writeBuffers.clear();
    restartConnection();

}
Ejemplo n.º 2
0
void MainWindow::enterRoom(){
    // add current ip to history
    if(!Config.HistoryIPs.contains(Config.HostAddress)){
        Config.HistoryIPs << Config.HostAddress;
        Config.HistoryIPs.sort();
        Config.setValue("HistoryIPs", Config.HistoryIPs);
    }

    ui->actionStart_Game->setEnabled(false);
    ui->actionStart_Server->setEnabled(false);

    int player_count = Sanguosha->getPlayerCount(ServerInfo.GameMode);
    RoomScene *room_scene = new RoomScene(player_count, this);

    ui->actionView_Discarded->setEnabled(true);
    ui->actionView_distance->setEnabled(true);
    ui->actionServerInformation->setEnabled(true);
    ui->actionKick->setEnabled(true);
    ui->actionSurrender->setEnabled(true);
    ui->actionSaveRecord->setEnabled(true);

    connect(ui->actionView_Discarded, SIGNAL(triggered()), room_scene, SLOT(toggleDiscards()));
    connect(ui->actionView_distance, SIGNAL(triggered()), room_scene, SLOT(viewDistance()));
    connect(ui->actionServerInformation, SIGNAL(triggered()), room_scene, SLOT(showServerInformation()));
    connect(ui->actionKick, SIGNAL(triggered()), room_scene, SLOT(kick()));
    connect(ui->actionSurrender, SIGNAL(triggered()), room_scene, SLOT(surrender()));
    connect(ui->actionSaveRecord, SIGNAL(triggered()), room_scene, SLOT(saveReplayRecord()));

    connect(room_scene, SIGNAL(restart()), this, SLOT(restartConnection()));

    gotoScene(room_scene);
}
Ejemplo n.º 3
0
void connection::checkPingTimeout()
{
    if (tglt_get_double_time () - m_lastReceiveTime > 6 * PING_TIMEOUT)
    {
        restartConnection();
    }
    else if (tglt_get_double_time () - m_lastReceiveTime > 3 * PING_TIMEOUT && this->state() == QAbstractSocket::ConnectedState)
    {
        tgl_do_send_ping(m_TLS, this);
    }
}
Ejemplo n.º 4
0
ZMClient::ZMClient()
    : QObject(NULL),
      m_listLock(QMutex::Recursive),
      m_socket(NULL),
      m_socketLock(QMutex::Recursive),
      m_hostname("localhost"),
      m_port(6548),
      m_bConnected(false),
      m_retryTimer(new QTimer(this)),
      m_zmclientReady(false),
      m_isMiniPlayerEnabled(true)
{
    setObjectName("ZMClient");
    connect(m_retryTimer, SIGNAL(timeout()),   this, SLOT(restartConnection()));

    gCoreContext->addListener(this);
}
Ejemplo n.º 5
0
LCD::LCD()
    : QObject(),
      m_socket(nullptr),              m_socketLock(QMutex::Recursive),
      m_hostname("localhost"),        m_port(6545),
      m_connected(false),

      m_retryTimer(new QTimer(this)), m_LEDTimer(new QTimer(this)),

      m_lcdWidth(0),                 m_lcdHeight(0),

      m_lcdReady(false),             m_lcdShowTime(false),
      m_lcdShowMenu(false),          m_lcdShowGeneric(false),
      m_lcdShowMusic(false),         m_lcdShowChannel(false),
      m_lcdShowVolume(false),        m_lcdShowRecStatus(false),
      m_lcdBacklightOn(false),       m_lcdHeartbeatOn(false),

      m_lcdPopupTime(0),

      m_lcdShowMusicItems(),
      m_lcdKeyString(),

      m_lcdLedMask(0),
      GetLEDMask(nullptr)
{
    m_sendBuffer.clear(); m_lastCommand.clear();
    m_lcdShowMusicItems.clear(); m_lcdKeyString.clear();

    setObjectName("LCD");

    // Constructor for LCD
    //
    // Note that this does *not* include opening the socket and initiating
    // communications with the LDCd daemon.

    LOG(VB_GENERAL, LOG_DEBUG, LOC +
        "An LCD object now exists (LCD() was called)");

    connect(m_retryTimer, SIGNAL(timeout()),   this, SLOT(restartConnection()));
    connect(m_LEDTimer,   SIGNAL(timeout()),   this, SLOT(outputLEDs()));
    connect(this, &LCD::sendToServer, this, &LCD::sendToServerSlot, Qt::QueuedConnection);
}