io.netty.buffer.ByteBuf.writeChar()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(4.6k)|赞(0)|评价(0)|浏览(184)

本文整理了Java中io.netty.buffer.ByteBuf.writeChar()方法的一些代码示例,展示了ByteBuf.writeChar()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ByteBuf.writeChar()方法的具体详情如下:
包路径:io.netty.buffer.ByteBuf
类名称:ByteBuf
方法名:writeChar

ByteBuf.writeChar介绍

[英]Sets the specified 2-byte UTF-16 character at the current writerIndex and increases the writerIndex by 2in this buffer. The 16 high-order bits of the specified value are ignored.
[中]在当前writerIndex处设置指定的2字节UTF-16字符,并在此缓冲区中将writerIndex增加2。指定值的16个高位将被忽略。

代码示例

代码示例来源:origin: netty/netty

@Override
public ByteBuf writeChar(int value) {
  buf.writeChar(value);
  return this;
}

代码示例来源:origin: netty/netty

@Override
public void writeChar(int v) throws IOException {
  buffer.writeChar(v);
}

代码示例来源:origin: redisson/redisson

@Override
public ByteBuf writeChar(int value) {
  buf.writeChar(value);
  return this;
}

代码示例来源:origin: redisson/redisson

@Override
public void writeChar(int v) throws IOException {
  buffer.writeChar(v);
}

代码示例来源:origin: netty/netty

@Override
public void writeChars(String s) throws IOException {
  int len = s.length();
  for (int i = 0 ; i < len ; i ++) {
    buffer.writeChar(s.charAt(i));
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public ByteBuf writeChar(int value) {
  buf.writeChar(value);
  return this;
}

代码示例来源:origin: micronaut-projects/micronaut-core

@Override
public ByteBuf writeChar(int value) {
  byteBuf.writeChar(value);
  return this;
}

代码示例来源:origin: wildfly/wildfly

@Override
public void writeChar(int v) throws IOException {
  buffer.writeChar(v);
}

代码示例来源:origin: normanmaurer/netty-in-action

@Override
  public void encode(ChannelHandlerContext ctx, Character msg,
    ByteBuf out) throws Exception {
    out.writeChar(msg);
  }
}

代码示例来源:origin: redisson/redisson

@Override
public void writeChars(String s) throws IOException {
  int len = s.length();
  for (int i = 0 ; i < len ; i ++) {
    buffer.writeChar(s.charAt(i));
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public void writeChars(String s) throws IOException {
  int len = s.length();
  for (int i = 0 ; i < len ; i ++) {
    buffer.writeChar(s.charAt(i));
  }
}

代码示例来源:origin: wildfly/wildfly

/**
   * Converts the current settings for the handler to the Base64-encoded representation used in
   * the HTTP2-Settings upgrade header.
   */
  private CharSequence getSettingsHeaderValue(ChannelHandlerContext ctx) {
    ByteBuf buf = null;
    ByteBuf encodedBuf = null;
    try {
      // Get the local settings for the handler.
      Http2Settings settings = connectionHandler.decoder().localSettings();

      // Serialize the payload of the SETTINGS frame.
      int payloadLength = SETTING_ENTRY_LENGTH * settings.size();
      buf = ctx.alloc().buffer(payloadLength);
      for (CharObjectMap.PrimitiveEntry<Long> entry : settings.entries()) {
        buf.writeChar(entry.key());
        buf.writeInt(entry.value().intValue());
      }

      // Base64 encode the payload and then convert to a string for the header.
      encodedBuf = Base64.encode(buf, URL_SAFE);
      return encodedBuf.toString(UTF_8);
    } finally {
      release(buf);
      release(encodedBuf);
    }
  }
}

代码示例来源:origin: wildfly/wildfly

@Override
public ChannelFuture writeSettings(ChannelHandlerContext ctx, Http2Settings settings,
    ChannelPromise promise) {
  try {
    checkNotNull(settings, "settings");
    int payloadLength = SETTING_ENTRY_LENGTH * settings.size();
    ByteBuf buf = ctx.alloc().buffer(FRAME_HEADER_LENGTH + settings.size() * SETTING_ENTRY_LENGTH);
    writeFrameHeaderInternal(buf, payloadLength, SETTINGS, new Http2Flags(), 0);
    for (Http2Settings.PrimitiveEntry<Long> entry : settings.entries()) {
      buf.writeChar(entry.key());
      buf.writeInt(entry.value().intValue());
    }
    return ctx.write(buf, promise);
  } catch (Throwable t) {
    return promise.setFailure(t);
  }
}

代码示例来源:origin: io.netty/netty-buffer

@Override
public ByteBuf writeChar(int value) {
  buf.writeChar(value);
  return this;
}

代码示例来源:origin: io.netty/netty-buffer

@Override
public void writeChar(int v) throws IOException {
  buffer.writeChar(v);
}

代码示例来源:origin: io.netty/netty-buffer

@Override
public void writeChars(String s) throws IOException {
  int len = s.length();
  for (int i = 0 ; i < len ; i ++) {
    buffer.writeChar(s.charAt(i));
  }
}

代码示例来源:origin: SpigotMC/BungeeCord

@Override
  protected void encode(ChannelHandlerContext ctx, String msg, ByteBuf out) throws Exception
  {
    out.writeByte( 0xFF );
    out.writeShort( msg.length() );
    for ( char c : msg.toCharArray() )
    {
      out.writeChar( c );
    }
  }
}

代码示例来源:origin: SlimeKnights/TinkersConstruct

@Override
 public void toBytes(ByteBuf buf) {
  buf.writeShort(categories.size());
  for(ConfigCategory category : categories) {
   buf.writeInt(category.values().size());
   ByteBufUtils.writeUTF8String(buf, category.getName());
   for(Property prop : category.values()) {
    ByteBufUtils.writeUTF8String(buf, prop.getName());
    buf.writeChar(prop.getType().getID());
    ByteBufUtils.writeUTF8String(buf, prop.getString()); // always has string representation of the value
   }
  }
 }
}

代码示例来源:origin: apache/activemq-artemis

@Override
public ByteBuf writeChar(int value) {
  buf.writeChar(value);
  return this;
}

代码示例来源:origin: org.apache.activemq/artemis-jms-client-all

@Override
public ByteBuf writeChar(int value) {
  buf.writeChar(value);
  return this;
}

相关文章

ByteBuf类方法