protected byte[] parseString(String str) { byte[][] bytess = new byte[2][]; bytess[1] = EzyStrings.getUtfBytes(str); bytess[0] = parseStringSize(bytess[1].Length); return(EzyBytes.merge(bytess)); }
protected byte[] parseBin(byte[] bin) { byte[][] bytess = new byte[2][]; bytess[0] = parseBinSize(bin.Length); bytess[1] = bin; return(EzyBytes.merge(bytess)); }
protected byte[] parseArray(EzyArray array) { int index = 1; int size = array.size(); byte[][] bytess = new byte[size + 1][]; bytess[0] = parseArraySize(size); for (int i = 0; i < size; i++) { bytess[index++] = serialize(array.get <Object>(i)); } return(EzyBytes.merge(bytess)); }
protected byte[] parseArray <T>(T[] array) { int index = 1; int size = array.Length; byte[][] bytess = new byte[size + 1][]; bytess[0] = parseArraySize(size); for (int i = 0; i < size; i++) { bytess[index++] = serialize(array[i]); } return(EzyBytes.merge(bytess)); }
protected byte[] parseObject(EzyObject obj) { int index = 1; int size = obj.size(); byte[][] bytess = new byte[size * 2 + 1][]; bytess[0] = parseMapSize(size); foreach (Object key in obj.keys()) { bytess[index++] = serialize(key); bytess[index++] = serialize(obj.get <Object>(key)); } return(EzyBytes.merge(bytess)); }
protected override void update() { byte[] readBytes = new byte[readBufferSize]; while (true) { if (!active) { return; } int bytesToRead = readSocketData(readBytes); if (bytesToRead <= 0) { return; } byte[] binary = EzyBytes.copyBytes(readBytes, bytesToRead); decoder.decode(binary, decodeBytesCallback); networkStatistics.getSocketStats().getNetworkStats().addReadBytes(binary.Length); networkStatistics.getSocketStats().getNetworkStats().addReadPackets(1); } }
public static EzyMessage bytesToMessage(byte[] bytes) { EzyMessageHeader header = EzyMessageHeaderReader.read(bytes[0]); int messageSizeLength = header.isBigSize() ? 4 : 2; int minSize = 2 + messageSizeLength; if (bytes.Length < minSize) { return(null); } byte[] messageSizeBytes = EzyBytes.copyBytes(bytes, 1, messageSizeLength); int messageSize = EzyInts.bin2int(messageSizeBytes); int allSize = 1 + messageSizeLength + messageSize; if (bytes.Length != allSize) { return(null); } int contentStart = 1 + messageSizeLength; byte[] messageContent = EzyBytes.copyBytes(bytes, contentStart, messageSize); return(new EzySimpleMessage(header, messageContent, messageSize)); }
public byte[] serialize(float value) { return(EzyBytes.getBytes(cast(0xca), value)); }
public byte[] serialize(double value) { return(EzyBytes.getBytes(cast(0xcb), value)); }
private byte[] parse64(long value) { return(EzyBytes.getBytes(0xd3, value, 8)); }
private byte[] parse32(long value) { return(EzyBytes.getBytes(0xd2, value, 4)); }
private byte[] parse16(long value) { return(EzyBytes.getBytes(0xd1, value, 2)); }
private byte[] parse8(long value) { return(EzyBytes.getBytes(0xd0, value, 1)); }
private byte[] parse32(int size) { return(EzyBytes.getBytes(0xdf, size, 4)); }
private byte[] parse16(int size) { return(EzyBytes.getBytes(0xde, size, 2)); }
private byte[] parse8(int size) { return(EzyBytes.getBytes(0xd9, size, 1)); }
private byte[] parseU8(long value) { return(EzyBytes.getBytes(0xcc, (byte)value)); }
private byte[] parse16(int size) { return(EzyBytes.getBytes(0xde, (short)size)); }
private byte[] parseU32(long value) { return(EzyBytes.getBytes(0xce, (int)value)); }
private byte[] parseU64(long value) { return(EzyBytes.getBytes(0xcf, value)); }
private byte[] parse16(long value) { return(EzyBytes.getBytes(0xd1, (short)value)); }