//создаем сокет для соединения клиентов
void InformerTCPServer::slotNewConnection()
{
    QTcpSocket *pClientSocket = m_ptcpServer->nextPendingConnection();
    connect(pClientSocket, SIGNAL(disconnected()), pClientSocket, SLOT(deleteLater()));
    connect(pClientSocket, SIGNAL(readyRead()),this, SLOT(slotReadClient()));
    sendToClient(pClientSocket, trUtf8("Сервак ответил")/*отправить сообщение клиенту "бла-бла-бла"*/);
}
void server::slotNewConnection()
{
    pClientSocket = m_ptcpServer->nextPendingConnection();
    qDebug() << "New client from IP-Adress:" << pClientSocket->peerAddress().toString();
    connect(pClientSocket, SIGNAL(disconnected()), pClientSocket, SLOT(deleteLater()));
    connect(pClientSocket, SIGNAL(readyRead()), this, SLOT(slotReadClient()) );
}
// ----------------------------------------------------------------------
void MyServer::slotNewConnection()
{
// если уже подключено максималное количество пользователей - отсоединяем всех новых
    if (i>=4)
    {
        QTcpSocket* pClientSocket_err = m_ptcpServer->nextPendingConnection();

        pClientSocket_err->close();

        return;
    }
// если пришел, запрос на подключение и у нас еще есть места для пользователей - создаем сокет для общения с ним
// и отправляем ему код для кодирования сообщения

    QTcpSocket* pClientSocket = m_ptcpServer->nextPendingConnection();

    connect(pClientSocket, SIGNAL(disconnected()) , this , SLOT(CloseConnection( pClientSocket)));

    connect(pClientSocket, SIGNAL(readyRead()), this , SLOT(slotReadClient()));

    for ( int j = 0; j < 4 ; j++ )
      if(clients[i].my_client == NULL)
        {
          clients[i].my_client = pClientSocket;

          clients[i].code = get_cdma_code();

          sendToClient_code(&clients[i] );

          i++;
          break;
        }
}
void MyServer::slotNewConnection ()
{
    QTcpSocket* pClientSocket = tcpServer->nextPendingConnection();

    connect(pClientSocket, SIGNAL(disconnected()), pClientSocket , SLOT(deleteLater()));

    connect(pClientSocket, SIGNAL(readyRead()), this , SLOT(slotReadClient()));
}
void AbstractServer::connectSignal(QTcpSocket* pClientSocket){
	 connect(pClientSocket, SIGNAL(disconnected()),
	            this, SLOT(slotClientDisconnect())
	           );
	 connect(pClientSocket, SIGNAL(readyRead()),
	            this, SLOT(slotReadClient())
	           );
}
void LibraryServer::slotNewConnection()
{
    QTcpSocket* Client = Server->nextPendingConnection();
    connect(Client, SIGNAL ( disconnected ( ) ),
            Client, SLOT   ( deleteLater  ( ) ));
    connect(Client, SIGNAL ( readyRead      ( ) ),
            this  , SLOT   ( slotReadClient ( ) ));
    qDebug() << "New client CONNECTED!";
}
void AbstractServer::disconnectSignal(QTcpSocket* pClientSocket){
	qDebug() << "AbstractServer::disconnectSignal# disconnect socket" << pClientSocket->socketDescriptor();
	disconnect(pClientSocket, SIGNAL(disconnected()),
			this, SLOT(slotClientDisconnect())
           );
	disconnect(pClientSocket, SIGNAL(readyRead()),
            this,          SLOT(slotReadClient())
           );
}
Exemple #8
0
void CGalconServer::slotNewConnection()
{
   QTcpSocket* pClientSocket = m_tcpServer->nextPendingConnection();
   pClientSocket->setProperty(socketID, ++m_currentClientID);
   m_connectedSockets.insert(SocketIDPair(m_currentClientID, pClientSocket));

   connect(pClientSocket,SIGNAL(disconnected()), this, SLOT(removeSocket()));
   connect(pClientSocket, SIGNAL(disconnected()), pClientSocket, SLOT(deleteLater()));
   connect(pClientSocket, SIGNAL(readyRead()), this, SLOT(slotReadClient()));
}
Exemple #9
0
void ourtrackserv::slotNewUser()
{
  while(tcpServer->hasPendingConnections())
  {
    QTcpSocket *clientSocket = tcpServer->nextPendingConnection();
    int idusersocs = clientSocket->socketDescriptor();
    SClients[idusersocs] = clientSocket;
    connect(SClients[idusersocs], SIGNAL(readyRead()), this, SLOT(slotReadClient()));
    qDebug() << "New user connect: " << QString::number(idusersocs);
  }
}
Exemple #10
0
void Server::slotNewConnection()
{
	QTcpSocket* pClientSocket = ptcpServer->nextPendingConnection();
	connect(pClientSocket, SIGNAL(disconnected()), pClientSocket, SLOT(deleteLater()));
	connect(pClientSocket, SIGNAL(readyRead()), this, SLOT(slotReadClient()));
	QString str = "Server Response: Connected!!";
	QString* pstr = &str;
	sendToClient(pClientSocket, *pstr);
	QString buf = "New client connected: Новий клієнт" + pClientSocket->peerAddress().toString();
	emit signal_display(buf);
	clients.insert(pClientSocket->peerAddress().toString(), pClientSocket);
}
Exemple #11
0
// ----------------------------------------------------------------------
/*virtual*/ void DServer::slotNewConnection()
{
    QTcpSocket* pClientSocket = m_ptcpServer->nextPendingConnection();
    connect(pClientSocket, SIGNAL(disconnected()), this, SLOT(deleteClientSocket()) );
    connect(pClientSocket, SIGNAL(readyRead()), this,          SLOT(slotReadClient()) );

    pClientSockets.append(pClientSocket);

    sendMessageToSocket(pClientSocket, "Server Response: Connected!");
    m_ptxt->append(QString::number( pClientSocket->localPort())+" is Connected");

     emit NewConnection();
}
Exemple #12
0
void my_server::slotNewConnection()
{
    QTcpSocket* pClientSocket = m_ptcpServer->nextPendingConnection();
    int id_user_socket = pClientSocket->socketDescriptor();
    map_clients[id_user_socket]  = new client(pClientSocket);

    connect(pClientSocket, SIGNAL(disconnected()), this, SLOT(slotDisconnected()));
    connect(pClientSocket, SIGNAL(readyRead()), this, SLOT(slotReadClient()));

    map_clients[id_user_socket]->sendToClient("123456789");
    emit map_to_combo_box(this->map_clients);
    emit text_to_console("Client connected!");

}
Exemple #13
0
void WakeServer::newuser()
{
    QTcpSocket* clientSocket=tcpServer->nextPendingConnection();
    qDebug() << QString::fromUtf8("New connection! ") + clientSocket->peerAddress().toString() + ":" + QString::number(clientSocket->peerPort());
    int idusersocs=clientSocket->socketDescriptor();
    SClients[idusersocs]=clientSocket;
    connect(SClients[idusersocs],SIGNAL(readyRead()),this, SLOT(slotReadClient()));
    //    tcpSocket = tcpServer->nextPendingConnection();
    //    if(tcpSocket->state() == QTcpSocket::ConnectedState)
    //    {
    //        qDebug() << "New connection established.";
    //    }
    //    //connect(connect, SIGNAL(disconnected()), this, SLOT(on_disconnected()));
    //    connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(slotReadClient()));
}
void TcpSockets::incoming(qintptr ID)
{
  QTcpSocket* socket = new QTcpSocket();

  while( SClients.isEmpty() == false )
  {
    SClients[ SClients.lastKey() ]->close();
    SClients.remove( SClients.lastKey() );
  }

  if(!socket->setSocketDescriptor(ID))
  {
    emit error(socket->error());
        qDebug() << "error";
    return;
  }

  SClients[ID]=socket;
  connect(SClients[ID],SIGNAL(readyRead()),this, SLOT(slotReadClient()));

}
Exemple #15
0
void Server::slotNewConnection()
{
    sender = myServer->nextPendingConnection();
    connect(sender, SIGNAL(disconnected()), sender, SLOT(deleteLater()));
    connect(sender, SIGNAL(readyRead()), this, SLOT(slotReadClient()));
}