private static string MessageBoundary() { ByteBuffer buffer = ByteBuffer.allocate(Short.BYTES); buffer.putShort(( short )0); buffer.flip(); return(ByteBufUtil.hexDump(buffer.array())); }
private static string ChunkContaining(params Number[] values) { short chunkSize = 0; foreach (Number value in values) { if (value is sbyte?) { chunkSize += Byte.BYTES; } else if (value is short?) { chunkSize += Short.BYTES; } else if (value is int?) { chunkSize += Integer.BYTES; } else if (value is long?) { chunkSize += Long.BYTES; } else if (value is double?) { chunkSize += Double.BYTES; } else { throw new System.ArgumentException("Unsupported number " + value.GetType() + ' ' + value); } } ByteBuffer buffer = ByteBuffer.allocate(chunkSize + CHUNK_HEADER_SIZE); buffer.putShort(chunkSize); foreach (Number value in values) { if (value is sbyte?) { buffer.put(value.byteValue()); } else if (value is short?) { buffer.putShort(value.shortValue()); } else if (value is int?) { buffer.putInt(value.intValue()); } else if (value is long?) { buffer.putLong(value.longValue()); } else if (value is double?) { buffer.putDouble(value.doubleValue()); } else { throw new System.ArgumentException("Unsupported number " + value.GetType() + ' ' + value); } } buffer.flip(); return(ByteBufUtil.hexDump(buffer.array())); }
private static void AssertByteBufEqual(ByteBuf buf, string hexContent) { assertEquals(ByteBufUtil.hexDump(buf), hexContent); }