Example usage for io.netty.buffer ByteBuf writeByte

List of usage examples for io.netty.buffer ByteBuf writeByte

Introduction

In this page you can find the example usage for io.netty.buffer ByteBuf writeByte.

Prototype

public abstract ByteBuf writeByte(int value);

Source Link

Document

Sets the specified byte at the current writerIndex and increases the writerIndex by 1 in this buffer.

Usage

From source file:com.friz.game.network.codec.LoginEncoder.java

License:Open Source License

@Override
protected void encode(ChannelHandlerContext ctx, Object msg, ByteBuf out) throws Exception {
    out.writeByte(2);
}

From source file:com.friz.game.network.codec.LoginInitEncoder.java

License:Open Source License

@Override
protected void encode(ChannelHandlerContext ctx, LoginInitResponseEvent msg, ByteBuf buf) throws Exception {
    buf.writeByte(msg.getStatus());
}

From source file:com.friz.lobby.network.codec.CreationEncoder.java

License:Open Source License

@Override
protected void encode(ChannelHandlerContext ctx, CreationResponseEvent msg, ByteBuf buf) throws Exception {
    buf.writeByte(msg.getStatus());
}

From source file:com.friz.lobby.network.codec.LobbyInitEncoder.java

License:Open Source License

@Override
protected void encode(ChannelHandlerContext ctx, LobbyInitResponseEvent msg, ByteBuf buf) throws Exception {
    buf.writeByte(msg.getStatus());
}

From source file:com.friz.network.utility.BufferUtils.java

License:Open Source License

/**
 * Puts a 5 byte integer into the buffer.
 * @param buf The channel buffer// w ww.  j  a  v a2  s .c  o  m
 * @param value The value to be added.
 */
public static void put5ByteInteger(ByteBuf buf, long value) {
    buf.writeByte((int) (value >> 32));
    buf.writeInt((int) (value));
}

From source file:com.friz.network.utility.BufferUtils.java

License:Open Source License

/**
 * Writes a string/*from  w ww. ja  v a2 s . co m*/
 * @param buffer The ChannelBuffer
 * @param string The string being wrote.
 */
public static void putJagString(ByteBuf buffer, String string) {
    buffer.writeByte(0);
    buffer.writeBytes(string.getBytes());
    buffer.writeByte(0);
}

From source file:com.friz.network.utility.BufferUtils.java

License:Open Source License

/**
 * Puts a string into a buffer./* ww w. ja v a 2 s . c  om*/
 * @param buf The buffer.
 * @param string The string.
 */
public static void putString(ByteBuf buf, String string) {
    for (char c : string.toCharArray()) {
        buf.writeByte(c);
    }
    buf.writeByte(0);
}

From source file:com.friz.update.network.codec.UpdateEncoder.java

License:Open Source License

@Override
protected void encode(ChannelHandlerContext ctx, FileResponseEvent msg, ByteBuf buffer) throws Exception {
    ByteBuf container = msg.getContainer();
    int type = msg.getType();
    int file = msg.getFile();

    if (!msg.isPriority())
        file |= 0x80000000;//from  w w w  .j  a  va  2s .co m

    buffer.writeByte(type);
    buffer.writeInt(file);

    int bytes = container.readableBytes();
    if (bytes > BYTES_AFTER_HEADER)
        bytes = BYTES_AFTER_HEADER;

    buffer.writeBytes(container.readBytes(bytes));

    for (;;) {
        bytes = container.readableBytes();
        if (bytes == 0)
            break;
        else if (bytes > BYTES_AFTER_HEADER)
            bytes = BYTES_AFTER_HEADER;

        buffer.writeByte(type);
        buffer.writeInt(file);
        buffer.writeBytes(container.readBytes(bytes));
    }
}

From source file:com.friz.update.network.codec.UpdateInitEncoder.java

License:Open Source License

@Override
protected void encode(ChannelHandlerContext ctx, UpdateResponseEvent msg, ByteBuf out) throws Exception {
    out.writeByte(msg.getStatus());
    if (msg.getStatus() == UpdateResponseEvent.STATUS_OK) {
        for (int i = 0; i < PERCENT_DELTA.length; i++) {
            out.writeInt(PERCENT_DELTA[i]);
        }/* w w w. ja va  2  s .  com*/
    }
}

From source file:com.friz.update.network.codec.XorEncoder.java

License:Open Source License

@Override
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception {
    while (msg.isReadable()) {
        out.writeByte(msg.readUnsignedByte() ^ key);
    }/* w  w w . j a  va2s.  c o  m*/
}