//if someone connects to the map server, send the current_map
void map_server(int socket, char *map_id)
{
    struct sockaddr_storage remote_addr;
    socklen_t addr_size;
    addr_size = sizeof(remote_addr);
    int map_request_connection = -1;
    if ((map_request_connection = accept(socket, (struct sockaddr*)&remote_addr, &addr_size)) < 0){
        printf("[NEW CONNECTION] Error in the incoming connection %s\n", strerror(errno));
    }
    printf("[MAP SERVER] Sending map %s\n", map_id);
    send_map(map_request_connection, map_id);
    close(map_request_connection);
}
Пример #2
0
bool		f_graphic(t_server *server, t_client *client)
{
  char		size[27];

  client->graphic = true;
  memset(size, 0, 27);
  trantorien_destroy(&client->trant);
  sprintf(size, "msz %d %d\n", server->args->x,
	  server->args->y);
  reponse_to_client(client->fd, size, server, 27);
  send_time(server, client);
  send_map(server);
  if (send_team(server, client) == false)
    g_quit = false;
  send_players(server);
  return (true);
}
Пример #3
0
void	init_graph(t_env *env, int cs)
{
  env->clt[cs].type = FD_GRAPH;
  env->cs_graphic = cs;
  env->clt[cs].g = 2;
  env->first = 1;
  sprintf(env->clt[cs].buf_write, "msz %i %i\n",
	  env->xwidth, env->ylength);
  xsend(env->cs_graphic, env->clt[cs].buf_write,
	strlen(env->clt[cs].buf_write), "G");
  sprintf(env->clt[cs].buf_write, "sgt %i\n",
	  (int)(env->timeunity));
  xsend(env->cs_graphic, env->clt[cs].buf_write,
	strlen(env->clt[cs].buf_write), "G");
  send_map(env);
  send_team(env);
  send_players(env);
}