/** * Creates a new empty text frame. */ public TextWebSocketFrame() { super(Unpooled.buffer(0)); }
/** * Creates a new empty close frame. */ public CloseWebSocketFrame() { super(Unpooled.buffer(0)); }
/** * Create a new {@link DefaultFullBinaryMemcacheResponse} with the header, key and extras. * * @param key the key to use. * @param extras the extras to use. */ public DefaultFullBinaryMemcacheResponse(ByteBuf key, ByteBuf extras) { this(key, extras, Unpooled.buffer(0)); }
/** * Creates a new empty pong frame. */ public PongWebSocketFrame() { super(Unpooled.buffer(0)); }
/** * Creates a new instance. * * @param streamId the Stream-ID of this frame */ public DefaultSpdyDataFrame(int streamId) { this(streamId, Unpooled.buffer(0)); }
/** * Create a new {@link DefaultBinaryMemcacheRequest} with the header, key and extras. * * @param key the key to use. * @param extras the extras to use. */ public DefaultFullBinaryMemcacheRequest(ByteBuf key, ByteBuf extras) { this(key, extras, Unpooled.buffer(0)); }
/** * Creates a new empty ping frame. */ public PingWebSocketFrame() { super(true, 0, Unpooled.buffer(0)); }
/** * Creates a new empty continuation frame. */ public ContinuationWebSocketFrame() { this(Unpooled.buffer(0)); }
/** * Creates a new empty binary frame. */ public BinaryWebSocketFrame() { super(Unpooled.buffer(0)); }
/** * Creates a new 8-byte big-endian buffer that holds the specified 64-bit integer. */ public static ByteBuf copyLong(long value) { ByteBuf buf = buffer(8); buf.writeLong(value); return buf; }
/** * Creates a new 4-byte big-endian buffer that holds the specified 32-bit integer. */ public static ByteBuf copyInt(int value) { ByteBuf buf = buffer(4); buf.writeInt(value); return buf; }
/** * Creates a new 8-byte big-endian buffer that holds the specified 64-bit floating point number. */ public static ByteBuf copyDouble(double value) { ByteBuf buf = buffer(8); buf.writeDouble(value); return buf; }
/** * Creates a new 2-byte big-endian buffer that holds the specified 16-bit integer. */ public static ByteBuf copyShort(int value) { ByteBuf buf = buffer(2); buf.writeShort(value); return buf; }
/** * Creates a new 3-byte big-endian buffer that holds the specified 24-bit integer. */ public static ByteBuf copyMedium(int value) { ByteBuf buf = buffer(3); buf.writeMedium(value); return buf; }
/** * Creates a new 4-byte big-endian buffer that holds the specified 32-bit floating point number. */ public static ByteBuf copyFloat(float value) { ByteBuf buf = buffer(4); buf.writeFloat(value); return buf; }
/** * Creates a new single-byte big-endian buffer that holds the specified boolean value. */ public static ByteBuf copyBoolean(boolean value) { ByteBuf buf = buffer(1); buf.writeBoolean(value); return buf; }
private static ByteBuf newBinaryData(int statusCode, String reasonText) { if (reasonText == null) { reasonText = StringUtil.EMPTY_STRING; } ByteBuf binaryData = Unpooled.buffer(2 + reasonText.length()); binaryData.writeShort(statusCode); if (!reasonText.isEmpty()) { binaryData.writeCharSequence(reasonText, CharsetUtil.UTF_8); } binaryData.readerIndex(0); return binaryData; }
@Override public ByteBuf copy(int index, int length) { checkIndex(index, length); ByteBuf dst = Unpooled.buffer(length); if (length != 0) { copyTo(index, length, toComponentIndex(index), dst); } return dst; }
@Override public FullHttpMessage copyIfNeeded(FullHttpMessage msg) { if (msg instanceof FullHttpRequest) { FullHttpRequest copy = ((FullHttpRequest) msg).replace(Unpooled.buffer(0)); copy.headers().remove(HttpHeaderNames.EXPECT); return copy; } return null; } };
public MqttPublishMessage build() { MqttFixedHeader mqttFixedHeader = new MqttFixedHeader(MqttMessageType.PUBLISH, false, qos, retained, 0); MqttPublishVariableHeader mqttVariableHeader = new MqttPublishVariableHeader(topic, messageId); return new MqttPublishMessage(mqttFixedHeader, mqttVariableHeader, Unpooled.buffer().writeBytes(payload)); } }