Package io.netty.buffer

Examples of io.netty.buffer.ByteBuf.writeByte()


      @Override
      public void write(ChannelHandlerContext ctx, Object msg,
          ChannelPromise promise) throws Exception {
        if (msg instanceof RemoteRxEvent){
          ByteBuf buf = ctx.alloc().buffer();
          buf.writeByte(PROTOCOL_VERSION);
          RemoteRxEvent event = (RemoteRxEvent) msg;
          String observableName = event.getName();
          if (observableName != null && !observableName.isEmpty()){
            // write length
            int nameLength = observableName.length();
View Full Code Here


          String observableName = event.getName();
          if (observableName != null && !observableName.isEmpty()){
            // write length
            int nameLength = observableName.length();
            if (nameLength < 127){
              buf.writeByte(nameLength);
              buf.writeBytes(observableName.getBytes());
            }else{
              throw new RuntimeException("observableName "+observableName+
                  " exceeds max limit of 127 characters");
            }
View Full Code Here

              throw new RuntimeException("observableName "+observableName+
                  " exceeds max limit of 127 characters");
            }
          }else{
            // no name provided, write 0 bytes for name length
            buf.writeByte(0);
          }
          if (event.getType() == RemoteRxEvent.Type.next){
                      logger.debug("WRITE request for RemoteRxEvent: next");
            buf.writeByte(1);
            buf.writeBytes(event.getData());
View Full Code Here

            // no name provided, write 0 bytes for name length
            buf.writeByte(0);
          }
          if (event.getType() == RemoteRxEvent.Type.next){
                      logger.debug("WRITE request for RemoteRxEvent: next");
            buf.writeByte(1);
            buf.writeBytes(event.getData());
            super.write(ctx, buf, promise);
          }else if (event.getType() == RemoteRxEvent.Type.error){
                      logger.debug("WRITE request for RemoteRxEvent: error");
            buf.writeByte(2);
View Full Code Here

            buf.writeByte(1);
            buf.writeBytes(event.getData());
            super.write(ctx, buf, promise);
          }else if (event.getType() == RemoteRxEvent.Type.error){
                      logger.debug("WRITE request for RemoteRxEvent: error");
            buf.writeByte(2);
            buf.writeBytes(event.getData());
            super.write(ctx, buf, promise);
          }else if (event.getType() == RemoteRxEvent.Type.completed){
                      logger.debug("WRITE request for RemoteRxEvent: completed");
            buf.writeByte(3);
View Full Code Here

            buf.writeByte(2);
            buf.writeBytes(event.getData());
            super.write(ctx, buf, promise);
          }else if (event.getType() == RemoteRxEvent.Type.completed){
                      logger.debug("WRITE request for RemoteRxEvent: completed");
            buf.writeByte(3);
            super.write(ctx, buf, promise);
            super.flush(ctx); // TODO why do I need to explicitly call flush for this to work??? empty data??
          }else if (event.getType() == RemoteRxEvent.Type.subscribed){
                      logger.debug("WRITE request for RemoteRxEvent: subscribed");
            buf.writeByte(4);
View Full Code Here

            buf.writeByte(3);
            super.write(ctx, buf, promise);
            super.flush(ctx); // TODO why do I need to explicitly call flush for this to work??? empty data??
          }else if (event.getType() == RemoteRxEvent.Type.subscribed){
                      logger.debug("WRITE request for RemoteRxEvent: subscribed");
            buf.writeByte(4);
            Map<String,String> subscribeParameters = event.getSubscribeParameters();
            if (subscribeParameters != null && !subscribeParameters.isEmpty()){
              byte[] subscribeBytes = fromMapToBytes(subscribeParameters);
              buf.writeInt(subscribeBytes.length); // write int for length
              buf.writeBytes(subscribeBytes); // write data
View Full Code Here

            }
            super.write(ctx, buf, promise);
            super.flush(ctx);
          }else if (event.getType() == RemoteRxEvent.Type.unsubscribed){
                      logger.debug("WRITE request for RemoteRxEvent: unsubscribed");
            buf.writeByte(5);
            super.write(ctx, buf, promise);
            super.flush(ctx); // TODO why do I need to explicitly call flush for this to work??? empty data??
          }
        }else{
          super.write(ctx, msg, promise);
View Full Code Here

  public ByteBuf encode(RegisterPluginChannelMessage message) {
    ByteBuf buffer = Unpooled.buffer();
    for (Iterator<String> i = message.getTypes().iterator(); i.hasNext(); ) {
      buffer.writeBytes(i.next().getBytes(CharsetUtil.UTF_8));
      if (i.hasNext()) {
        buffer.writeByte(0);
      }
    }
    return buffer;
  }
View Full Code Here

  }

  @Override
  public ByteBuf writeHeader(MessageCodec<?> codec, ByteBuf data) {
    ByteBuf buffer = Unpooled.buffer(1);
    buffer.writeByte(codec.getOpcode());
    return buffer;
  }

  @Override
  public Message getKickMessage(String message) {
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.