Search in sources :

Example 1 with GameMessageEncoder

use of org.apollo.net.codec.game.GameMessageEncoder in project apollo by apollo-rsps.

the class LoginSession method sendLoginSuccess.

/**
 * Sends a succesfull {@link LoginResponse} to the client.
 *
 * @param player The {@link Player} that successfully logged in.
 */
public void sendLoginSuccess(Player player) {
    IsaacRandomPair randomPair = request.getRandomPair();
    boolean flagged = false;
    GameSession session = new GameSession(channel, context, player, request.isReconnecting());
    channel.attr(ApolloHandler.SESSION_KEY).set(session);
    player.setSession(session);
    int rights = player.getPrivilegeLevel().toInteger();
    channel.writeAndFlush(new LoginResponse(LoginConstants.STATUS_OK, rights, flagged));
    Release release = context.getRelease();
    channel.pipeline().addFirst("messageEncoder", new GameMessageEncoder(release));
    channel.pipeline().addBefore("messageEncoder", "gameEncoder", new GamePacketEncoder(randomPair.getEncodingRandom()));
    channel.pipeline().addBefore("handler", "gameDecoder", new GamePacketDecoder(randomPair.getDecodingRandom(), context.getRelease()));
    channel.pipeline().addAfter("gameDecoder", "messageDecoder", new GameMessageDecoder(release));
    channel.pipeline().remove("loginDecoder");
    channel.pipeline().remove("loginEncoder");
}
Also used : LoginResponse(org.apollo.net.codec.login.LoginResponse) GameMessageDecoder(org.apollo.net.codec.game.GameMessageDecoder) GamePacketEncoder(org.apollo.net.codec.game.GamePacketEncoder) GamePacketDecoder(org.apollo.net.codec.game.GamePacketDecoder) GameMessageEncoder(org.apollo.net.codec.game.GameMessageEncoder) IsaacRandomPair(org.apollo.util.security.IsaacRandomPair) Release(org.apollo.net.release.Release)

Aggregations

GameMessageDecoder (org.apollo.net.codec.game.GameMessageDecoder)1 GameMessageEncoder (org.apollo.net.codec.game.GameMessageEncoder)1 GamePacketDecoder (org.apollo.net.codec.game.GamePacketDecoder)1 GamePacketEncoder (org.apollo.net.codec.game.GamePacketEncoder)1 LoginResponse (org.apollo.net.codec.login.LoginResponse)1 Release (org.apollo.net.release.Release)1 IsaacRandomPair (org.apollo.util.security.IsaacRandomPair)1