void Handover::handleNewConnection() { if (m_remote) m_remote->deleteLater(); m_remote = m_server->nextPendingConnection(); connect(m_remote, SIGNAL(disconnected()), this, SLOT(remoteDisconnected())); sendBluetoothService(); }
RemoteClient::RemoteClient(TCPSocket *s) : state(1), lastpingtime(QTime::currentTime()) { MessageReceiver *rr = new MessageReceiver(s); connect(rr, SIGNAL(chatMessageReceive(ChatMessage)), this, SLOT(remoteChatMessageReceive(ChatMessage))); connect(rr, SIGNAL(tryToConnectMessageReceive(TryToConnectMessage)), this, SLOT(remoteTryToConnectMessageReceive(TryToConnectMessage))); connect(rr, SIGNAL(pingMessageReceive(PingMessage)), this, SLOT(remotePingMessageReceive(PingMessage))); connect(rr, SIGNAL(turnMessageReceive(TurnMessage)), this, SLOT(remoteTurnMessageReceive(TurnMessage))); connect(rr, SIGNAL(surrenderMessageReceive(SurrenderMessage)), this, SLOT(remoteSurrenderMessageReceive(SurrenderMessage))); connect(s, SIGNAL(disconnected()), this, SLOT(remoteDisconnected())); connect(s, SIGNAL(error()), this, SLOT(remoteError())); this->socket = s; this->receiver = rr; this->state = 1; }
CGProxy::CGProxy(QWidget* parent) : QObject(parent), m_LocalSocket(0) { m_LocalServer = new QTcpServer(this); m_ListenPort = 6125; while(!m_LocalServer->listen(QHostAddress::LocalHost, m_ListenPort)) m_ListenPort++; connect(m_LocalServer, SIGNAL(newConnection()), this, SLOT(newConnection())); m_RequesterSocket = new QUdpSocket(this); m_RequesterSocket->bind(m_ListenPort, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint); connect(m_RequesterSocket, SIGNAL(readyRead()), this, SLOT(readPendingDatagrams())); m_GameProtocol = new CGameProtocol(); timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(update())); timer->start(30); m_TotalPacketsReceivedFromLocal = 0; m_TotalPacketsReceivedFromRemote = 0; m_LastConnectionAttemptTime = 0; m_GameIsReliable = false; m_GameStarted = false; m_LeaveGameSent = false; m_ActionReceived = false; m_Synchronized = true; m_ReconnectPort = 0; m_PID = 255; m_ChatPID = 255; m_ReconnectKey = 0; m_NumEmptyActions = 0; m_NumEmptyActionsUsed = 0; m_LastAckTime = 0; m_LastActionTime = 0; m_LastBroadcastTime = 0; m_RemoteSocket = new QTcpSocket(this); connect(m_RemoteSocket, SIGNAL(disconnected()), this, SLOT(remoteDisconnected())); connect(m_RemoteSocket, SIGNAL(readyRead()), this, SLOT(readServerPackets())); }