Display the lobby, a game room, or the add guest for the user.
439228
function gameOrLobby(games) {
    $(LOBBY).hide();
    $(GAMEROOM).hide();
    $(ADDGUEST).hide();

    if (!$.cookie("player")) {
        drawAddGuest();
        return;
    }

    // hide the fork me banner from now on
    $(FORKME).hide();

    var my_game = $.cookie("game");
    // User is not in a valid game
    if (typeof games[my_game] === 'undefined') {
        $.removeCookie('game');
        $(LOBBY).show();
        drawLobby(games);
    } else {
        $(GAMEROOM).show();
        drawGame();
    }
    $(CHATPNL).show();
    drawChatLog();
    drawChatIn();

    // setup future calls to get chat
    function pollChat() {
        drawChatLog();
        DRAWCHATTID = setTimeout(pollChat, 2000);
    }
    DRAWCHATTID = setTimeout(pollChat, 2000);
}
1363758
@Override
    public void switchPlayerToSpectator(ApiBaseUser user) {
        try {
            room.switchPlayerToSpectator(CommandUtil.getSfsUser(user, api));
        } catch (SFSRoomException e) {
            throw new IllegalStateException(e);
        }
    }
1135091
function onGetPlayers(pdata) {
    $(PLAYERS).empty();
    // display all players
    for (var p in pdata) {
        if (!pdata.hasOwnProperty(p)) {
            continue;
        }
        var turn = pdata[p].has_turn ? "has_turn" : "";
        $(PLAYERS).append("<dt class='" + turn + "'>" + esc(p) + "</dt>" +
                          "<dd>" + pdata[p].points + "</dd>");
    }

    var my_game = $.cookie("game");
    var my_player = $.cookie("player");
    if (my_player) {
        if (pdata[my_player] === undefined) {
            // I've got a player name, but we need to add it to the game
            $.post("/games/" + enc(my_game) + "/players", {name: my_player},
                   function() {getPlayers();});
        } else if (HAVETURN !== pdata[my_player].has_turn) {
            HAVETURN = pdata[my_player].has_turn;
            if (HAVETURN) {
                countdownTimer();
            } else {
                clearTimeout(COUNTDOWNTID);
            }
            drawTurnInfo(pdata);
        }
    }
}
1334955
protected function initRoomsTable(): void
    {
        $this->rooms = new Table($this->config['room_rows']);
        $this->rooms->column('value', Table::TYPE_STRING, $this->config['room_size']);
        $this->rooms->create();
    }
817926
def setWorkingPlayAreaSize(self, sizeX, sizeZ):
        """"""

        fn = self.function_table.setWorkingPlayAreaSize
        fn(sizeX, sizeZ)
516932
def enter_room(self, sid, namespace, room):
        """"""
        if namespace not in self.rooms:
            self.rooms[namespace] = {}
        if room not in self.rooms[namespace]:
            self.rooms[namespace][room] = {}
        self.rooms[namespace][room][sid] = True
392221
def _handle_userCount(self, data):
        """"""

        self.room.user_count = data
        self.conn.enqueue_data("user_count", self.room.user_count)
539572
def human():
  """"""
  run_config = run_configs.get()

  map_inst = maps.get(FLAGS.map)

  if not FLAGS.rgb_screen_size or not FLAGS.rgb_minimap_size:
    logging.info("Use --rgb_screen_size and --rgb_minimap_size if you want rgb "
                 "observations.")

  ports = [FLAGS.config_port + p for p in range(5)]  # tcp + 2 * num_players
  if not all(portpicker.is_port_free(p) for p in ports):
    sys.exit("Need 5 free ports after the config port.")

  proc = None
  ssh_proc = None
  tcp_conn = None
  udp_sock = None
  try:
    proc = run_config.start(extra_ports=ports[1:], timeout_seconds=300,
                            host=FLAGS.host, window_loc=(50, 50))

    tcp_port = ports[0]
    settings = {
        "remote": FLAGS.remote,
        "game_version": proc.version.game_version,
        "realtime": FLAGS.realtime,
        "map_name": map_inst.name,
        "map_path": map_inst.path,
        "map_data": map_inst.data(run_config),
        "ports": {
            "server": {"game": ports[1], "base": ports[2]},
            "client": {"game": ports[3], "base": ports[4]},
        }
    }

    create = sc_pb.RequestCreateGame(
        realtime=settings["realtime"],
        local_map=sc_pb.LocalMap(map_path=settings["map_path"]))
    create.player_setup.add(type=sc_pb.Participant)
    create.player_setup.add(type=sc_pb.Participant)

    controller = proc.controller
    controller.save_map(settings["map_path"], settings["map_data"])
    controller.create_game(create)

    if FLAGS.remote:
      ssh_proc = lan_sc2_env.forward_ports(
          FLAGS.remote, proc.host, [settings["ports"]["client"]["base"]],
          [tcp_port, settings["ports"]["server"]["base"]])

    print("-" * 80)
    print("Join: play_vs_agent --host %s --config_port %s" % (proc.host,
                                                              tcp_port))
    print("-" * 80)

    tcp_conn = lan_sc2_env.tcp_server(
        lan_sc2_env.Addr(proc.host, tcp_port), settings)

    if FLAGS.remote:
      udp_sock = lan_sc2_env.udp_server(
          lan_sc2_env.Addr(proc.host, settings["ports"]["client"]["game"]))

      lan_sc2_env.daemon_thread(
          lan_sc2_env.tcp_to_udp,
          (tcp_conn, udp_sock,
           lan_sc2_env.Addr(proc.host, settings["ports"]["server"]["game"])))

      lan_sc2_env.daemon_thread(lan_sc2_env.udp_to_tcp, (udp_sock, tcp_conn))

    join = sc_pb.RequestJoinGame()
    join.shared_port = 0  # unused
    join.server_ports.game_port = settings["ports"]["server"]["game"]
    join.server_ports.base_port = settings["ports"]["server"]["base"]
    join.client_ports.add(game_port=settings["ports"]["client"]["game"],
                          base_port=settings["ports"]["client"]["base"])

    join.race = sc2_env.Race[FLAGS.user_race]
    join.player_name = FLAGS.user_name
    if FLAGS.render:
      join.options.raw = True
      join.options.score = True
      if FLAGS.feature_screen_size and FLAGS.feature_minimap_size:
        fl = join.options.feature_layer
        fl.width = 24
        FLAGS.feature_screen_size.assign_to(fl.resolution)
        FLAGS.feature_minimap_size.assign_to(fl.minimap_resolution)
      if FLAGS.rgb_screen_size and FLAGS.rgb_minimap_size:
        FLAGS.rgb_screen_size.assign_to(join.options.render.resolution)
        FLAGS.rgb_minimap_size.assign_to(join.options.render.minimap_resolution)
    controller.join_game(join)

    if FLAGS.render:
      renderer = renderer_human.RendererHuman(
          fps=FLAGS.fps, render_feature_grid=False)
      renderer.run(run_configs.get(), controller, max_episodes=1)
    else:  # Still step forward so the Mac/Windows renderer works.
      while True:
        frame_start_time = time.time()
        if not FLAGS.realtime:
          controller.step()
        obs = controller.observe()

        if obs.player_result:
          break
        time.sleep(max(0, frame_start_time - time.time() + 1 / FLAGS.fps))
  except KeyboardInterrupt:
    pass
  finally:
    if tcp_conn:
      tcp_conn.close()
    if proc:
      proc.close()
    if udp_sock:
      udp_sock.close()
    if ssh_proc:
      ssh_proc.terminate()
      for _ in range(5):
        if ssh_proc.poll() is not None:
          break
        time.sleep(1)
      if ssh_proc.poll() is None:
        ssh_proc.kill()
        ssh_proc.wait()
558131
def groups_invite(self, room_id, user_id, **kwargs):
        """"""
        return self.__call_api_post('groups.invite', roomId=room_id, userId=user_id, kwargs=kwargs)
1190151
function(msg) {
      var gameOverElement = document.getElementById('gameOver'),
          gameOverMsgElement = document.getElementById('gameOverMsg'),
          waitingForPlayerElem = document.getElementById('waitingForPlayer');
      if (msg === false)  {
        gameOverElement.style.display = 'none';
      }
      else {
        gameOverMsgElement.innerText = msg;
        gameOverElement.style.display = 'block';
        waitingForPlayerElem.style.display = 'none';
      }
    }
929313
def _get_private_room(self, invitees: List[User]):
        
        return self._client.create_room(
            None,
            invitees=[user.user_id for user in invitees],
            is_public=False,
        )
965851
public function create_room($name, $owner_user_id = null, $privacy = null, $topic = null, $guest_access = null) {
     $args = array(
       'name' => $name
     );

     if ($owner_user_id) {
       $args['owner_user_id'] = $owner_user_id;
     }

     if ($privacy) {
       $args['privacy'] = $privacy;
     }

     if ($topic) {
       $args['topic'] = $topic;
     }

     if ($guest_access) {
       $args['guest_access'] = (int)$guest_access;
     }

     // Return the std object
     return $this->make_request('rooms/create', $args, 'POST');
    }
202983
def join_room(self, room_name):   
             
        logging.debug('Joining room {ro}'.format(ro=room_name))

        for room in self.rooms:
            if room.name == room_name:
                room.add_user(self)
                self._rooms[room_name] = room
                room.welcome(self)
                break
        else:
            room = Room(room_name)
            self.rooms.append(room)
            self._rooms[room_name] = room
            room.add_user(self)
189434
def listen_many(*rooms):
    """"""

    rooms = set(r.conn for r in rooms)
    for room in rooms:
        room.validate_listeners()
    with ARBITRATOR.condition:
        while any(r.connected for r in rooms):
            ARBITRATOR.condition.wait()
            rooms = [r for r in rooms if r.run_queues()]
            if not rooms:
                return
744255
function GameServer(options, channel) {
    EventEmitter.call(this);
    this.setMaxListeners(0);

    /**
     * ### GameServer.options
     *
     * Reference to the user options defined in the server channel
     */
    this.options = options;

    /**
     * ### GameServer.channel
     *
     * Reference to the _ServerChannel_ in which the game server is created
     *
     * @see ServerChannel
     */
    this.channel = channel;

    /**
     * ### GameServer.servernode
     *
     * Reference to the _ServerNode_
     *
     * @see ServerNode
     */
    this.servernode = this.channel.servernode;

    /**
     * ### GameServer.registry
     *
     * Reference to _ChannelRegistry_ inside the server channel
     *
     * @see GameServer.channel
     * @see ChannelRegistry
     */
    this.registry = channel.registry;

    /**
     * ### GameServer.session
     *
     * The session ID as created by the channel.
     */
    this.session = channel.session;

    /**
     * ### GameServer.endpoint
     *
     * The endpoint under which the server is reachable
     */
    this.endpoint = '/' + options.endpoint;

    /**
     * ### GameServer.name
     *
     * The name of the server
     */
    this.name = options.name;

    /**
     * ### GameServer.serverid
     *
     * A random id for the server
     */
    this.serverid = '' + Math.random()*1000000000;

    /**
     * ### GameServer.sysLogger
     *
     * Logger of system events
     */
    this.sysLogger = Logger.get('channel', { name: this.name });

    /**
     * ### GameServer.msgLogger
     *
     * Logger of incoming / outgoing game messages
     */
    this.msgLogger = Logger.get('messages', { name: this.name });

    /**
     * ### GameServer.socket
     *
     * Socket manager for the server
     *
     * @see SocketManager
     */
    this.socketManager = new SocketManager(this);

    /**
     * ### GameServer.msg
     *
     * Game message generator
     *
     * @see GameMsgGenerator
     */
    this.msg = new GameMsgGenerator(this);

    /**
     * ### GameServer.partner
     *
     * The partner game server (Admin or Player)
     *
     * @see AdminServer
     * @see PlayerServer
     */
    this.partner = null;

    /**
     * ### GameServer.sio
     *
     * Reference to the Socket.io App in the ServerNode
     *
     * @see ServerNode
     * @see ServerChannel
     */
    this.sio = channel.sio;

    /**
     * ### GameServer.authCb
     *
     * An authorization callback
     */
    this.authCb = null;

    /**
     * ### GameServer.accessDeniedUrl
     *
     * The url of the page to which unauthorized clients will be redirected
     */
    this.accessDeniedUrl = options.accessDeniedUrl;

    /**
     * ### GameServer.generateClientId
     *
     * Client IDs generator callback.
     */
    this.generateClientId = null;

    /**
     * ### GameServer.enableReconnections
     *
     * If TRUE, clients can reconnect to same game room
     *
     * Clients will be matched with previous game history based on
     * the clientId found in their cookies.
     */
    this.enableReconnections = !!options.enableReconnections;

    /**
     * ### GameServer.antiSpoofing
     *
     * If TRUE, server asks clients to send along their sid in each msg
     */
    this.antiSpoofing = !!options.antiSpoofing;


}
1353278
def invite(user, reason='')
      response = self.class.post(@api.invite_config[:url]+"/#{user}",
        :query => { :auth_token => @token },
        :body => {
          :reason => reason
        }.to_json,
        :headers => @api.headers)

      ErrorHandler.response_code_to_exception_for :room, room_id, response
      true
    end
62163
public void displayMenu() {
        while (true) {
            ConsoleMenu.println("");
            ConsoleMenu.println("Menu Options");

            final int size = menu.size();

            displayMenu(size);

            int opt;

            do {
                opt = ConsoleMenu.getInt("Enter your choice:", -1);
            } while ((opt <= 0 || opt > methods.size()) && opt != EXIT_CODE);

            if (opt == EXIT_CODE) {
                callTearDownIfRequired();
                return;
            }

            callMenuOption(opt);
        }
    }