Exemplo n.º 1
0
void * boucle_recv(void * arg) {
  int sock_serv = *(int*)arg;
  FILE * flux = fdopen(sock_serv, "r");
  while(1) {
    recevoir(flux);
  }
}
Exemplo n.º 2
0
void * receiverThread(void* arg)
{
	int lg_message = LG_MESS_DEFAUT;
	
	initReceiver();
	setUser(1);
	while(1)
		recevoir(lg_message, msgRcv);
	return NULL;
}
void ServeurLabyrinthe::Start()
{
	std::string message;
	while (true)
	{
		while(est_invalide(m_socketClient))
		{
			accepter_client();
		}

		message = tolowercase(recevoir());

		switch (message[0])
		{
			case DROITE: 
            m_Carte.tryMoveRight();
				break;
			case GAUCHE:
            m_Carte.tryMoveLeft();
				break;
			case HAUT:
            m_Carte.tryMoveUp();
            break;
         case BAS:
            m_Carte.tryMoveDown();
				break;
			default:
				break;
		}

      if (m_Carte.is_PartieFinie())
      {
         envoyer("*");
      }
      else
      {
         // Envoyer nouveau vecteur.
         std::vector<std::vector<char>> vector = m_Carte.getVec();

         for (int y = 0; y < m_Carte.height(); ++y)
         {
            std::string s(vector[y].begin(), vector[y].end());

            envoyer(s);
         }

         envoyer("@");
      }
	}
}
Exemplo n.º 4
0
void envoi_chemin_ricochet (Robot* robot)
{
    int receive;
    while(chemin_ricochet.size() != 0)
    {
        switch(chemin_ricochet.back())
        {
            case HAUT:
                send_direction (robot->id,HAUT,0);
                receive = recevoir(robot->id);

                send_direction (robot->id,0,0);

                receive = recevoir(robot->id);

                break;
            case BAS:
                send_direction (robot->id,BAS,0);
                receive = recevoir(robot->id);

                send_direction (robot->id,0,0);

                receive = recevoir(robot->id);
                break;
            case DROITE:
                send_direction (robot->id,DROITE,0);
                receive = recevoir(robot->id);

                send_direction (robot->id,0,0);

                receive = recevoir(robot->id);
                break;
            case GAUCHE:
                send_direction (robot->id,GAUCHE,0);
                receive = recevoir(robot->id);

                send_direction (robot->id,0,0);

                receive = recevoir(robot->id);
                break;
        }
        chemin_ricochet.pop_back();
    }
}