public void handleGameRoomJoin(Player player, Channel channel, ChannelBuffer buffer) { String refKey = NettyUtils.readString(buffer); GameRoom gameRoom = lookupService.gameRoomLookup(refKey); if (null != gameRoom) { PlayerSession playerSession = gameRoom.createPlayerSession(); playerSession.setConnectParameter( NettyUtils.NETTY_CHANNEL, channel); // TODO is this required? gameRoom.onLogin(playerSession); LOG.trace("Sending GAME_ROOM_JOIN_SUCCESS to channel {}", channel.getId()); ChannelFuture future = channel.write(NettyUtils.createBufferForOpcode(Events.GAME_ROOM_JOIN_SUCCESS)); connectToGameRoom(gameRoom, playerSession, future); loginUdp(playerSession, buffer); } else { // Write failure and close channel. ChannelFuture future = channel.write(NettyUtils.createBufferForOpcode(Events.GAME_ROOM_JOIN_FAILURE)); future.addListener(ChannelFutureListener.CLOSE); LOG.error( "Invalid ref key provided by client: {}. Channel {} will be closed", refKey, channel.getId()); } }
public Player lookupPlayer(final ChannelBuffer buffer, final Channel channel) { Credentials credentials = new SimpleCredentials(buffer); Player player = lookupService.playerLookup(credentials); if (null == player) { LOG.error("Invalid credentials provided by user: {}", credentials); } return player; }