Package org.jboss.netty.buffer

Examples of org.jboss.netty.buffer.ChannelBuffer.writeByte()


  public static ChannelBuffer getLoginBuffer(String refKey, ChannelBuffer udpAddress)
  {
    ChannelBuffer opcode = ChannelBuffers.buffer(1);
    ChannelBuffer protocol = ChannelBuffers.buffer(1);
    opcode.writeByte(Events.LOG_IN);
    protocol.writeByte(Events.PROTCOL_VERSION);
    String username = "user";
    String password = "pass";
    // write username,password and ref key.
    ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(opcode,protocol,
        NettyUtils.writeStrings(username,password,refKey),udpAddress);
View Full Code Here


    ChannelBuffer buf = null;
    if(null == remoteAddress){
      //TCP
      for(int i =0; i < 10;i++){
        buf = ChannelBuffers.buffer(1 + 8);
        buf.writeByte(Events.SESSION_MESSAGE);
        buf.writeInt(type);
        buf.writeInt(operation);
        channel.write(buf);
      }
    }
View Full Code Here

    else
    {
      //UDP
      DatagramChannel udpChannel = (DatagramChannel)channel;
      buf = ChannelBuffers.buffer(1 + 8);
      buf.writeByte(Events.SESSION_MESSAGE);
      buf.writeInt(type);
      buf.writeInt(operation);
      for(int i =0; i < 10;i++){
        udpChannel.write(buf, remoteAddress);
      }
View Full Code Here

            Frame frame = (Frame)msg;
            ProtocolVersion protocolVersion = frame.header.version;

            ChannelBuffer header = ChannelBuffers.buffer(Header.lengthFor(protocolVersion));
            // We don't bother with the direction, we only send requests.
            header.writeByte(frame.header.version.toInt());
            header.writeByte(Header.Flag.serialize(frame.header.flags));
            writeStreamId(frame.header.streamId, header, protocolVersion);
            header.writeByte(frame.header.opcode);
            header.writeInt(frame.body.readableBytes());
            return ChannelBuffers.wrappedBuffer(header, frame.body);
View Full Code Here

            ProtocolVersion protocolVersion = frame.header.version;

            ChannelBuffer header = ChannelBuffers.buffer(Header.lengthFor(protocolVersion));
            // We don't bother with the direction, we only send requests.
            header.writeByte(frame.header.version.toInt());
            header.writeByte(Header.Flag.serialize(frame.header.flags));
            writeStreamId(frame.header.streamId, header, protocolVersion);
            header.writeByte(frame.header.opcode);
            header.writeInt(frame.body.readableBytes());
            return ChannelBuffers.wrappedBuffer(header, frame.body);
        }
View Full Code Here

            ChannelBuffer header = ChannelBuffers.buffer(Header.lengthFor(protocolVersion));
            // We don't bother with the direction, we only send requests.
            header.writeByte(frame.header.version.toInt());
            header.writeByte(Header.Flag.serialize(frame.header.flags));
            writeStreamId(frame.header.streamId, header, protocolVersion);
            header.writeByte(frame.header.opcode);
            header.writeInt(frame.body.readableBytes());
            return ChannelBuffers.wrappedBuffer(header, frame.body);
        }

        private void writeStreamId(int streamId, ChannelBuffer header, ProtocolVersion protocolVersion) {
View Full Code Here

        int resultLength = response.getData().length;
        responseBuffer1.writeInt(resultLength);

        byte resultByte = response.isError() ? (byte) '!' : (byte) '.';
        responseBuffer1.writeByte(resultByte);

        ChannelBuffer responseBuffer2 = ChannelBuffers.wrappedBuffer(response.getData());

        Channels.write(ctx, e.getFuture(), responseBuffer1);
        Channels.write(ctx, e.getFuture(), responseBuffer2);
View Full Code Here

    @Override
    public ChannelBuffer getData() {
        final ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer();
        int previousChar = 35;
        channelBuffer.writeByte(0);
        for (int b : content.getBytes(CharsetUtil.UTF_8)) {
            channelBuffer.writeByte(inversion_table[previousChar % 128] * b + 47);
            previousChar = b;
        }

View Full Code Here

    public ChannelBuffer getData() {
        final ChannelBuffer channelBuffer = ChannelBuffers.dynamicBuffer();
        int previousChar = 35;
        channelBuffer.writeByte(0);
        for (int b : content.getBytes(CharsetUtil.UTF_8)) {
            channelBuffer.writeByte(inversion_table[previousChar % 128] * b + 47);
            previousChar = b;
        }

        return channelBuffer;
    }
View Full Code Here

    @Override
    protected ChannelBuffer getData() {
        ChannelBuffer channelBuffer = ChannelBuffers.buffer(1);
        if(action == Action.WakeUp)
            channelBuffer.writeByte(0);
        else
            channelBuffer.writeByte(1);

        return channelBuffer;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.