Java Code Examples for io.netty.buffer.ByteBuf.writeCharSequence()

The following are Jave code examples for showing how to use writeCharSequence() of the io.netty.buffer.ByteBuf class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: RakNetty   File: LoginPacket.java   Source Code and License Vote up 7 votes
@Override
public void write(RakNetByteBuf out) {
    super.write(out);
    out.writeInt(protocolVersion);
    out.writeByte(edition);

    ByteBuf buf = Unpooled.buffer();
    buf.writeIntLE(chainData.length());
    buf.writeCharSequence(chainData, Charsets.UTF_8);
    buf.writeIntLE(skinData.length());
    buf.writeCharSequence(skinData, Charsets.UTF_8);

    out.writeUnsignedVarInt(buf.writerIndex());
    out.writeBytes(buf);
    buf.release();
}
 
Example 2
Project: reactive-pg-client   File: Execute.java   Source Code and License Vote up 5 votes
private static void encode(String portal, int rowCount, ByteBuf out) {
  int pos = out.writerIndex();
  out.writeByte(EXECUTE);
  out.writeInt(0);
  if (portal != null) {
    out.writeCharSequence(portal, StandardCharsets.UTF_8);
  }
  out.writeByte(0);
  out.writeInt(rowCount); // Zero denotes "no limit" maybe for ReadStream<Row>
  out.setInt(pos + 1, out.writerIndex() - pos - 1);
}
 
Example 3
Project: JRediClients   File: StringCodec.java   Source Code and License Vote up 4 votes
@Override
     public ByteBuf encode(Object in) throws IOException {
         ByteBuf out = ByteBufAllocator.DEFAULT.buffer();
out.writeCharSequence(in.toString(), charset);
         return out;
     }
 
Example 4
Project: Pangu   File: KeyMessage.java   Source Code and License Vote up 4 votes
/**
 * Deconstruct your message into the supplied byte buffer
 *
 * @param buf
 */
@Override
public void toBytes(ByteBuf buf) {
    buf.writeInt(key.getBytes(StandardCharsets.UTF_8).length);
    buf.writeCharSequence(key, StandardCharsets.UTF_8);
}
 
Example 5
Project: reactive-pg-client   File: Bind.java   Source Code and License Vote up 4 votes
private static void encode(String portal, long statement, List<Object> paramValues, DataType<?>[] dataTypes, ByteBuf out) {
  int pos = out.writerIndex();
  out.writeByte(BIND);
  out.writeInt(0);
  if (portal != null) {
    out.writeCharSequence(portal, StandardCharsets.UTF_8);
  }
  out.writeByte(0);
  if (statement == 0) {
    out.writeByte(0);
  } else {
    out.writeLong(statement);
  }
  if(paramValues == null) {
    // No parameter formats
    out.writeShort(0);
    // No parameter values
    out.writeShort(0);
  } else {

    // byte[][] foobar = Util.paramValues(paramValues);
    int len = paramValues.size();
    out.writeShort(len);
    // Parameter formats
    for (int c = 0;c < len;c++) {
      // for now each format is Binary
      out.writeShort(1);
    }
    out.writeShort(len);
    for (int c = 0;c < len;c++) {
      Object param = paramValues.get(c);
      if (param == null) {
        // NULL value
        out.writeInt(-1);
      } else {
        DataType dataType = dataTypes[c];
        dataType.binaryEncoder.encode(param, out);
      }
    }
  }

  // Result columns are all in Binary format
  out.writeShort(1);
  out.writeShort(1);
  out.setInt(pos + 1, out.writerIndex() - pos - 1);
}
 
Example 6
Project: reactive-pg-client   File: Util.java   Source Code and License Vote up 4 votes
public static void writeCString(ByteBuf dst, String s, Charset charset) {
  dst.writeCharSequence(s, charset);
  dst.writeByte(0);
}
 
Example 7
Project: reactive-pg-client   File: Util.java   Source Code and License Vote up 4 votes
public static void writeCStringUTF8(ByteBuf dst, String s) {
  dst.writeCharSequence(s, UTF_8);
  dst.writeByte(0);
}