Method which will create and add event handlers of the player session to
the Game Room's EventDispatcher.

@param playerSession
The session for which the event handlers are created.
336027
protected void createAndAddEventHandlers(PlayerSession playerSession)
	{
		// Create a network event listener for the player session.
		EventHandler networkEventHandler = new NetworkEventListener(playerSession);
		// Add the handler to the game room's EventDispatcher so that it will
		// pass game room network events to player session session.
		this.eventDispatcher.addHandler(networkEventHandler);
		LOG.trace("Added Network handler to "
				+ "EventDispatcher of GameRoom {}, for session: {}", this,
				playerSession);
	}
295960
@Override
    public synchronized void controllerUpdate(ControllerEvent ce) {

        Player p = (Player) ce.getSourceController();

        if (p == null)
            return;

        // Get this when the internal players are realized.
        if (ce instanceof RealizeCompleteEvent) {
            p.start();
        }

        if (ce instanceof ControllerErrorEvent) {
            p.removeControllerListener(this);
            LOGGER.severe("Receiver internal error: " + ce);
        }

    }
1062263
public void triggerSessionCreated(JingleSession jingleSession) {
        jingleSessions.add(jingleSession);
        jingleSession.addListener(this);
        for (CreatedJingleSessionListener createdJingleSessionListener : creationListeners) {
            try {
                createdJingleSessionListener.sessionCreated(jingleSession);
            } catch (Exception e) {
                LOGGER.log(Level.WARNING, "exception", e);
            }
        }
    }
884344
private void sendEvents(EventHolder event) {
    // Only send events to the client if this server is the leader.
    if (server.isLeader()) {
      eventExecutor.execute(() -> {
        PublishRequest request = PublishRequest.builder()
            .withSession(sessionId().id())
            .withEventIndex(event.eventIndex)
            .withPreviousIndex(event.previousIndex)
            .withEvents(event.events)
            .build();

        log.trace("Sending {}", request);
        protocol.publish(memberId(), request);
      });
    }
  }
21941
function handlePlayers(request, response, game, path) {
    var func, player, resp;
    if (!path.length) {
        // return info on the players collection

        if (request.method === "POST") {
            player = playerFromReq(request, response, game);
            if (player) {
                // end turn
                // TODO should this be under /players/<name>/?
                func = function (form) {
                    if (form && form.end_turn) {
                        switchPlayers(game, player);
                        respOk(response);
                    }
                };
            } else {
                // add player to a game
                func = function(form) {
                    if (form && form.name) {
                        addPlayerToGame(game, form.name);
                        var jar = new cookies(request, response);
                        jar.set("player", encodeURIComponent(form.name),
                                {httpOnly: false});
                        respOk(response, '', 'text/json');
                    }
                };
            }
            requestBody(request, func);
            return;
        } else if (request.method === 'DELETE') {
            // delete player from a game
            func = function(form) {
                if (form && form.name) {
                    player = game.players[form.name];
                    if (player === undefined) {
                        // huh? player is not in this game
                        response.writeHead(404, {'Content-Type': 'text/json'});
                        response.end();
                        return;
                    }
                    nextTurn(game, player);
                    game.returnPieces(player.pieces);
                    delete game.players[form.name];
                    if (Object.keys(game.players).length === 0) {
                        delete games[game.name];
                    }
                    respOk(response);
                }
            };
            requestBody(request, func);
            return;
        }  else {
            resp = JSON.stringify(game.players);
        }

    } else {
        // return info on a specific player
        player = game.players[path[0]];
        if (typeof player === 'undefined') {
            // player not found
            response.writeHead(404, {'Content-Type': 'text/json'});
            response.end();
            return;
        }

        if (path[1] === 'pieces') {
            resp = JSON.stringify(player.pieces);
        }
    }
    respOk(response, resp, 'text/json');
}
1059646
public void destorySession(Session session) {
        session.attributes().clear();
        sessionMap.remove(session.id());

        Event event = new Event();
        event.attribute("session", session);

        eventManager.fireEvent(EventType.SESSION_DESTROY, event);
    }
558155
private void enqueueSessionEvent(final IoSessionEvent evt) {
        synchronized (sessionEventsQueue) {
            logger.debug("Enqueuing event: {}", evt);
            sessionEventsQueue.offer(evt);
        }    
    }
666532
public void sessionDidActivate(SipSessionEvent event) {
		logger.info("Following sip session just activated " + event.getSession().getId() + " cause " + ((SipSessionActivationEvent)event).getCause());
		if(((SipSessionActivationEvent)event).getCause() == SessionActivationNotificationCause.FAILOVER) {
			event.getSession().setAttribute(SIP_SESSION_ACTIVATED, "true" );
		}
	}
173076
function Player(player) {
        var key;

        if ('object' !== typeof player) {
            throw new TypeError('Player constructor: player must be object. ' +
                               'Found: ' + player);
        }
        if ('string' !== typeof player.id) {
            throw new TypeError('Player constructor: id must be string. ' +
                                'Found: ' + player.id);
        }

        // ## Default properties

        /**
         * ### Player.id
         *
         * The nodeGame session id associate to the player
         *
         * Usually it is the same as the Socket.io id, but in
         * case of reconnections it can change
         */
        this.id = player.id;

        /**
         * ### Player.sid
         *
         * The session id received from the nodeGame server
         */
        this.sid = player.sid;

        /**
         * ### Player.clientType
         *
         * The client type (e.g. player, admin, bot, ...)
         */
        this.clientType = player.clientType || null;

        /**
         * ### Player.group
         *
         * The group to which the player belongs
         */
        this.group = player.group || null;

        /**
         * ### Player.role
         *
         * The role of the player
         */
        this.role = player.role || null;

        /**
         * ### Player.partner
         *
         * The partner of the player
         */
        this.partner = player.partner || null;

        /**
         * ### Player.count
         *
         * The ordinal position of the player in a PlayerList object
         *
         * @see PlayerList
         */
        this.count = 'undefined' === typeof player.count ? null : player.count;

        /**
         * ### Player.admin
         *
         * The admin status of the client
         */
        this.admin = !!player.admin;

        /**
         * ### Player.disconnected
         *
         * The connection status of the client
         */
        this.disconnected = !!player.disconnected;

        /**
         * ### Player.ip
         *
         * The ip address of the player
         *
         * Note: this can change in mobile networks
         */
        this.ip = player.ip || null;

        /**
         * ### Player.name
         *
         * An alphanumeric name associated with the player
         */
        this.name = player.name || null;

        /**
         * ### Player.stage
         *
         * Reference to the game-stage the player currently is
         *
         * @see node.game.stage
         * @see GameStage
         */
        this.stage = player.stage || new GameStage();

        /**
         * ### Player.stageLevel
         *
         * The current stage level of the player in the game
         *
         * @see node.stageLevels
         */
        this.stageLevel = player.stageLevel || stageLevels.UNINITIALIZED;

        /**
         * ### Player.stateLevel
         *
         * The current state level of the player in the game
         *
         * @see node.stateLevels
         */
        this.stateLevel = player.stateLevel || stateLevels.UNINITIALIZED;

        /**
         * ### Player.lang
         *
         * The current language used by the player
         *
         * Default language is English with the default path `en/`.
         */
        this.lang = {
            name: 'English',
            shortName: 'en',
            nativeName: 'English',
            path: 'en/'
        };

        /**
         * ## Extra properties
         *
         * For security reasons, they cannot be of type function, and they
         * cannot overwrite any previously defined variable
         */
        for (key in player) {
            if (player.hasOwnProperty(key)) {
                if ('function' !== typeof player[key]) {
                    if (!this.hasOwnProperty(key)) {
                        this[key] = player[key];
                    }
                }
            }
        }
    }
1315734
public void synchronize(CheerleaderPlayer player) {
        setTrack(player.getCurrentTrack());
        mLoader.setVisibility(INVISIBLE);
        mPlayPause.setVisibility(VISIBLE);
        setPlaying(player.isPlaying());
    }
1348974
function restartGame(players) {
    // Replace the current instance with a new instance
    let newGame = new RockPaperScissors(game, players, winCounter, id);
    proxy.swap(newGame);

    q.delay(RESULTS_DELAY)
      .done(function() {
        deferred.resolve(newGame.handleIt(callbacks));
      });
  }
74754
private void deliverFaderStartCommand(Set<Integer> playersToStart, Set<Integer> playersToStop) {
        for (final FaderStartListener listener : getFaderStartListeners()) {
            try {
                listener.fadersChanged(playersToStart, playersToStop);
            } catch (Throwable t) {
                logger.warn("Problem delivering fader start command to listener", t);
            }
        }
    }
474302
@SuppressWarnings("unchecked")
    @Override
    public void handleServerEvent(ISFSEvent event) throws SFSException {
        Zone sfsZone = (Zone) event.getParameter(SFSEventParam.ZONE);
        User sfsUser = (User) event.getParameter(SFSEventParam.USER);
        List<Room> sfsRooms = (List<Room>)event.getParameter(SFSEventParam.JOINED_ROOMS);
        Map<Room, Integer> sfsIds = (Map<Room, Integer>)event.getParameter(SFSEventParam.PLAYER_IDS_BY_ROOM);
        ClientDisconnectionReason sfsReason = (ClientDisconnectionReason)event.getParameter(SFSEventParam.DISCONNECTION_REASON);
        ApiUser apiUser = (ApiUser) sfsUser.getProperty(APIKey.USER);
        List<ApiRoom> apiRooms = CommandUtil.getApiRoomList(sfsRooms);
        apiUser.setProperty(APIKey.USER_JOINED_ROOMS, apiRooms);
        apiUser.setProperty(Constants.USER_JOINED_ROOMS, sfsRooms);
        ApiDisconnectionImpl apiDisconnection = new ApiDisconnectionImpl();
        apiDisconnection.setZone((ApiZone) sfsZone.getProperty(APIKey.ZONE));
        apiDisconnection.setUser(apiUser);
        apiDisconnection.setJoinedRooms(apiRooms);
        apiDisconnection.setPlayerIdsByRoom(convertPlayerIdsByRoom(sfsIds));
        apiDisconnection.setReason(sfsReason.toString());
        notifyHandlers(apiUser, apiDisconnection);
        notifyToRooms(sfsZone, sfsRooms, sfsUser);
        detachUserData(sfsUser);
    }
273676
@Override
	public final void onMessageSent(Session session, Object msg) {
		Command command = (Command) msg;
		((HandlerSocketSession) session).addCommand(command);

	}
477341
@Override
    public <P> void pojoDaoCreated(PojoDaoFactoryEvent<P> event) {
        event.getPojoBinding().verifySchema(session.getCluster().getMetadata().getKeyspace(session.getLoggedKeyspace()), event.getTableName());
    }
850697
public static void removeIngredientsFromPlayer(EntityPlayerMP player, List<ItemStack> ingredients)
    {
        NonNullList<ItemStack> main = player.inventory.mainInventory;
        NonNullList<ItemStack> arm = player.inventory.armorInventory;

        for (ItemStack isIngredient : ingredients)
        {
            int target = isIngredient.getCount();
            for (int i = 0; i < main.size() + arm.size() && target > 0; i++)
            {
                ItemStack isPlayer = (i >= main.size()) ? arm.get(i - main.size()) : main.get(i);
                if (isPlayer != null && isIngredient != null && itemStackIngredientsMatch(isPlayer, isIngredient))
                {
                    if (target >= isPlayer.getCount())
                    {
                        // Consume this stack:
                        target -= isPlayer.getCount();
                        if (i >= main.size())
                            arm.get(i - main.size()).setCount(0);
                        else
                            main.get(i).setCount(0);
                    }
                    else
                    {
                        isPlayer.setCount(isPlayer.getCount() - target);
                        target = 0;
                    }
                }
            }
            ItemStack resultForReward = isIngredient.copy();
            RewardForDiscardingItemImplementation.LoseItemEvent event = new RewardForDiscardingItemImplementation.LoseItemEvent(resultForReward);
            MinecraftForge.EVENT_BUS.post(event);
        }
    }
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);
        }
    }
}