Beispiel #1
0
void *requeteThread(void *param){
  client_t *client = (client_t *)param;
  int keep_alive = 0;
  int ret = 0;
  int endRequete = 0;

  initClientsBuffer(client);
  
  if(pthread_detach(pthread_self()) != 0){
    perror("pthread_detach");
    return NULL;
  }

  client->requete.use = 0;
  while((ret = readRequete(&client->requete, client->sock, &endRequete, true)) != -1){
    
    traiterRequete(client, ret, &keep_alive, endRequete);

    if(!keep_alive){
      break;
    }
  }

  if(client->sock != -1){
    printf("\e[31mdéconnexion du client (%s):%s (socket %d)\e[0m\n", client->host, client->serv, client->sock);
    deconnexionClient(client);
  }
ClientTcpPush::ClientTcpPush( QTcpSocket *sock,
                              QList<QByteArray> &video, int time ):
    sockControle(sock), images(video), imgCourante(-1), tpi(time)

{
    connect(sockControle, SIGNAL(readyRead()),
            this, SLOT(requeteRecu()));
    connect(this, SIGNAL(requeteComplete()),
            this, SLOT(traiterRequete()));
}
DemandeTcpPull::DemandeTcpPull( QTcpSocket *sock,
                                QList<QByteArray> &video):
        sockControle(sock), images(video)

{
    numImageEnvoie=0;
    sockDonnees = new QTcpSocket(this);
    connect(sockControle, SIGNAL(readyRead()),
           this, SLOT(requeteRecu()));
    connect(this, SIGNAL(requeteComplete()),
            this, SLOT(traiterRequete()));
}
void ServeurUdpPull::requeteRecu()
{
    qDebug()<<"requete recue";
    QByteArray requete;
    QHostAddress address;
    quint16 maxSize =sockecoute->pendingDatagramSize();
    requete.resize(maxSize);
    sockecoute->readDatagram(requete.data(),maxSize,&address);
    qDebug()<<requete;

    traiterRequete(requete,address);

}
int Client::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: requeteComplete(); break;
        case 1: demandeClient((*reinterpret_cast< QByteArray(*)>(_a[1]))); break;
        case 2: requeteRecu(); break;
        case 3: traiterRequete(); break;
        default: ;
        }
        _id -= 4;
    }
    return _id;
}