Esempio n. 1
0
/* validation de la connexion d'un utilisateur */
void bienvenue(char *name, int sock_com){
  char buffer[MAX_SIZE];
  client_list *tmp;

  pthread_mutex_lock(&mutex_clients);
  if(client_exists(clients, name)){
    /* si le nom du joueur est déjà pris */
    sprintf(buffer, "%s already used\n", name);
    write(sock_com, buffer, strlen(buffer));
    pthread_mutex_unlock(&mutex_clients);
  }else{
    /* ajout dans la file d'attente tant que le client n'est pas nommé */
    pthread_mutex_lock(&mutex_attente);
    file_attente = add_name_client(file_attente, sock_com, name);
    if(get_phase() == -1){
      /* transfert du client dans la file d'attente vers la liste des clients */
      tmp = get_client(file_attente, name);
      file_attente = suppr_client(file_attente, name);
      tmp->next = clients;
      clients = tmp;
    }
    sprintf(buffer, "BIENVENUE/%s/\n", name);
    write(sock_com, buffer, strlen(buffer));
    pthread_mutex_unlock(&mutex_clients);
    pthread_mutex_unlock(&mutex_attente);
    /* Notification à tous les clients de la connexion de ce joueur */
    connecte(name);
  }
  pthread_mutex_unlock(&mutex_clients);
}
Esempio n. 2
0
void XDCC::onConnexion()
{
	socket = server->nextPendingConnection();
	connect( socket, SIGNAL( connected() ), this, SLOT( connecte() ) );
	connect( socket, SIGNAL( disconnected() ), this, SLOT( deconnecte() ) );
	connect( socket, SIGNAL( error( QAbstractSocket::SocketError ) ), this, SIGNAL( onError( QAbstractSocket::SocketError ) ) );
}
Esempio n. 3
0
Client_Utils::Client_Utils(QTextEdit *liste) {
    listeMessages = liste;
    socket = new QTcpSocket(this);
    connect(socket, SIGNAL(readyRead()), this, SLOT(donneesRecues()));
    connect(socket, SIGNAL(connected()), this, SLOT(connecte()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(deconnecte()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(erreurSocket(QAbstractSocket::SocketError)));

    tailleMessage = 0;
}
Esempio n. 4
0
FenClient::FenClient()
{
    setupUi(this);

    socket = new QTcpSocket(this);
    connect(socket, SIGNAL(readyRead()), this, SLOT(donneesRecues()));
    connect(socket, SIGNAL(connected()), this, SLOT(connecte()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(deconnecte()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(erreurSocket(QAbstractSocket::SocketError)));
    //connect(checkBox, SIGNAL(stateChanged(int)),this, SLOT(coche()));//lance coche() si on choche la case
    //connect(checkBox, SIGNAL(stateChanged(int)),this, SLOT(decoche()));//lance decoche() si on déchoche la case
    //connect(pushButton, SIGNAL(clicked()),this, SLOT(pushAction()));//lance pushAction() si on lance l'action 2
    tailleMessage = 0;
}
interSocketClient::interSocketClient(QString address, int port, FenGenerale *parent) : m_sem(0), m_stockage(""),
    QMainWindow(parent)
{
    m_IG = parent;
    m_socket = new QTcpSocket;
    m_socket->connectToHost(address, port);

    connect(m_socket, SIGNAL(readyRead()), this, SLOT(donneesRecues()));
    connect(m_socket, SIGNAL(connected()), this, SLOT(connecte()));
    connect(m_socket, SIGNAL(disconnected()), this, SLOT(deconnecte()));
    connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(erreurSocket(QAbstractSocket::SocketError)));

    m_tailleMessage = 0;
}
Esempio n. 6
0
Client::Client()
{
    setupUi(this);
    messageLength = 0;
    pointeurMap= new QMap<void*, int>;
    socket = new QTcpSocket(this);

    connect(socket, SIGNAL(readyRead()), this, SLOT(receive_message()));
    connect(socket, SIGNAL(connected()), this, SLOT(connecte()));
    connect(socket, SIGNAL(disconnected()), this, SLOT(disconnecte()));
    connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(erreurSocket(QAbstractSocket::SocketError)));
    setWindowTitle(tr("Risk585 Client"));

}
Esempio n. 7
0
FenClient::FenClient(QWidget *parent) :
            ui(new Ui::FenClient)
{
    ui->setupUi(this);

    socket = new QTcpSocket(this);

    connect(socket,SIGNAL(readyRead()),this,SLOT(donneesRecues()));
    connect(socket,SIGNAL(connected()),this,SLOT(connecte()));
    connect(socket,SIGNAL(disconnected()),this,SLOT(deconnecte()));
    connect(socket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(erreurSocket(QAbstractSocket::SocketError)));
    connect(ui->pseudo,SIGNAL(textEdited(QString)),this,SLOT(pseudoObligatoire()));
    tailleMessage=0;
    ui->boutonEnvoyer->setEnabled(false);
}
Esempio n. 8
0
ChatWindow::ChatWindow(QWidget *parent)
: QWidget(parent), ui(new Ui::ChatWindowClass) {
    
    ui->setupUi(this);
    ui->splitter->hide();

    connect(ui->buttonConnect, SIGNAL(clicked()), this, SLOT(connecte()));
    connect(ui->actionQuit, SIGNAL(triggered()), this, SLOT(close()));
    connect(ui->actionCloseTab, SIGNAL(triggered()), this, SLOT(closeTab()));
    connect(ui->lineEdit, SIGNAL(returnPressed()), this, SLOT(sendCommand()));
    connect(ui->disconnect, SIGNAL(clicked()), this, SLOT(disconnectFromServer()));
    connect(ui->tab, SIGNAL(currentChanged(int)), this, SLOT(tabChanged(int)));
    connect(ui->tab, SIGNAL(tabCloseRequested(int)), this, SLOT(tabClosing(int)));
    
    connect(ui->userView, SIGNAL(clicked(const QModelIndex &) ), this, SLOT( userClicked() ) );
}
AuthForm::AuthForm(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::AuthForm)
{
    ui->setupUi(this);
    setFixedWidth(this->width());

    // paramétrage du socket
    m_socket = new QTcpSocket(this);
    connect(m_socket, SIGNAL(connected()), this, SLOT(connecte()));
    connect(m_socket, SIGNAL(disconnected()), this, SLOT(deconnecte()));
    connect(m_socket, SIGNAL(readyRead()), this, SLOT(reponseAuth()));
    connect(m_socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(erreurSocket(QAbstractSocket::SocketError)));

    // définition du focus
    ui->LoginEdit->setFocus();

    m_tailleMessage = 0;
}
Esempio n. 10
0
void RollitWidget::setPlayByNetwork(bool bo,QString iptxt,quint16 p)
{
qDebug()  << "playbynetwork" << bo;
playbynetwork=bo;

socket = new QTcpSocket(this);

QHostAddress ad(iptxt);


socket->connectToHost(ad,p,QIODevice::ReadWrite);
connect(socket, SIGNAL(readyRead()), this, SLOT(donneesRecues()));
connect(socket, SIGNAL(connected()), this, SLOT(connecte()));
connect(socket, SIGNAL(disconnected()), this, SLOT(deconnecte()));
connect(socket, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(erreurSocket(QAbstractSocket::SocketError)));

tailleMessage = 0;



return;


}