mirror of
https://github.com/esiur/esiur-dotnet.git
synced 2025-09-13 12:43:17 +00:00
codec
This commit is contained in:
@@ -180,13 +180,13 @@ public static class Codec
|
|||||||
/// <param name="connection">DistributedConnection is required in case a structure in the array holds items at the other end.</param>
|
/// <param name="connection">DistributedConnection is required in case a structure in the array holds items at the other end.</param>
|
||||||
/// <param name="dataType">DataType, in case the data is not prepended with DataType</param>
|
/// <param name="dataType">DataType, in case the data is not prepended with DataType</param>
|
||||||
/// <returns>Value</returns>
|
/// <returns>Value</returns>
|
||||||
public static (uint, object) ParseAsync(byte[] data, uint offset, DistributedConnection connection, uint[] requestSequence, TransmissionType? dataType = null)
|
public static (uint, object) ParseAsync(byte[] data, uint offset, DistributedConnection connection, uint[] requestSequence, TransmissionDataUnit? dataType = null)
|
||||||
{
|
{
|
||||||
uint len = 0;
|
uint len = 0;
|
||||||
|
|
||||||
if (dataType == null)
|
if (dataType == null)
|
||||||
{
|
{
|
||||||
(var longLen, dataType) = TransmissionType.Parse(data, offset, (uint)data.Length);
|
(var longLen, dataType) = TransmissionDataUnit.Parse(data, offset, (uint)data.Length);
|
||||||
|
|
||||||
if (dataType == null)
|
if (dataType == null)
|
||||||
throw new NullReferenceException("DataType can't be parsed.");
|
throw new NullReferenceException("DataType can't be parsed.");
|
||||||
@@ -201,27 +201,27 @@ public static class Codec
|
|||||||
|
|
||||||
//Console.WriteLine("Parsing " + tt.Class + " " + tt.Identifier);
|
//Console.WriteLine("Parsing " + tt.Class + " " + tt.Identifier);
|
||||||
|
|
||||||
if (tt.Class == TransmissionTypeClass.Fixed)
|
if (tt.Class == TransmissionDataUnitClass.Fixed)
|
||||||
{
|
{
|
||||||
return (len, FixedAsyncParsers[tt.Exponent][tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, connection, requestSequence));
|
return (len, FixedAsyncParsers[tt.Exponent][tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, connection, requestSequence));
|
||||||
}
|
}
|
||||||
else if (tt.Class == TransmissionTypeClass.Dynamic)
|
else if (tt.Class == TransmissionDataUnitClass.Dynamic)
|
||||||
{
|
{
|
||||||
return (len, DynamicAsyncParsers[tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, connection, requestSequence));
|
return (len, DynamicAsyncParsers[tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, connection, requestSequence));
|
||||||
}
|
}
|
||||||
else //if (tt.Class == TransmissionTypeClass.Typed)
|
else //if (tt.Class == TransmissionDataUnitClass.Typed)
|
||||||
{
|
{
|
||||||
return (len, TypedAsyncParsers[tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, connection, requestSequence));
|
return (len, TypedAsyncParsers[tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, connection, requestSequence));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (uint, object) ParseSync(byte[] data, uint offset, Warehouse warehouse, TransmissionType? dataType = null)
|
public static (uint, object) ParseSync(byte[] data, uint offset, Warehouse warehouse, TransmissionDataUnit? dataType = null)
|
||||||
{
|
{
|
||||||
uint len = 0;
|
uint len = 0;
|
||||||
|
|
||||||
if (dataType == null)
|
if (dataType == null)
|
||||||
{
|
{
|
||||||
(var longLen, dataType) = TransmissionType.Parse(data, offset, (uint)data.Length);
|
(var longLen, dataType) = TransmissionDataUnit.Parse(data, offset, (uint)data.Length);
|
||||||
|
|
||||||
if (dataType == null)
|
if (dataType == null)
|
||||||
throw new NullReferenceException("DataType can't be parsed.");
|
throw new NullReferenceException("DataType can't be parsed.");
|
||||||
@@ -234,15 +234,15 @@ public static class Codec
|
|||||||
|
|
||||||
var tt = dataType.Value;
|
var tt = dataType.Value;
|
||||||
|
|
||||||
if (tt.Class == TransmissionTypeClass.Fixed)
|
if (tt.Class == TransmissionDataUnitClass.Fixed)
|
||||||
{
|
{
|
||||||
return (len, FixedParsers[tt.Exponent][tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, warehouse));
|
return (len, FixedParsers[tt.Exponent][tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, warehouse));
|
||||||
}
|
}
|
||||||
else if (tt.Class == TransmissionTypeClass.Dynamic)
|
else if (tt.Class == TransmissionDataUnitClass.Dynamic)
|
||||||
{
|
{
|
||||||
return (len, DynamicParsers[tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, warehouse));
|
return (len, DynamicParsers[tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, warehouse));
|
||||||
}
|
}
|
||||||
else //if (tt.Class == TransmissionTypeClass.Typed)
|
else //if (tt.Class == TransmissionDataUnitClass.Typed)
|
||||||
{
|
{
|
||||||
return (len, TypedParsers[tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, warehouse));
|
return (len, TypedParsers[tt.Index](data, dataType.Value.Offset, (uint)tt.ContentLength, warehouse));
|
||||||
}
|
}
|
||||||
@@ -265,7 +265,7 @@ public static class Codec
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public delegate (TransmissionTypeIdentifier, byte[]) Composer(object value, Warehouse warehouse, DistributedConnection connection);
|
public delegate (TransmissionDataUnitIdentifier, byte[]) Composer(object value, Warehouse warehouse, DistributedConnection connection);
|
||||||
|
|
||||||
public static Dictionary<Type, Composer> Composers = new Dictionary<Type, Composer>()
|
public static Dictionary<Type, Composer> Composers = new Dictionary<Type, Composer>()
|
||||||
{
|
{
|
||||||
@@ -328,21 +328,21 @@ public static class Codec
|
|||||||
[typeof(PropertyValue[])] = DataSerializer.PropertyValueArrayComposer
|
[typeof(PropertyValue[])] = DataSerializer.PropertyValueArrayComposer
|
||||||
// Typed
|
// Typed
|
||||||
// [typeof(bool[])] = (value, con) => DataSerializer.TypedListComposer((IEnumerable)value, typeof(bool), con),
|
// [typeof(bool[])] = (value, con) => DataSerializer.TypedListComposer((IEnumerable)value, typeof(bool), con),
|
||||||
// [typeof(bool?[])] = (value, con) => (TransmissionTypeIdentifier.TypedList, new byte[] { (byte)value }),
|
// [typeof(bool?[])] = (value, con) => (TransmissionDataUnitIdentifier.TypedList, new byte[] { (byte)value }),
|
||||||
// [typeof(List<bool>)] = (value, con) => (TransmissionTypeIdentifier.TypedList, new byte[] { (byte)value }),
|
// [typeof(List<bool>)] = (value, con) => (TransmissionDataUnitIdentifier.TypedList, new byte[] { (byte)value }),
|
||||||
// [typeof(List<bool?>)] = (value, con) => (TransmissionTypeIdentifier.TypedList, new byte[] { (byte)value }),
|
// [typeof(List<bool?>)] = (value, con) => (TransmissionDataUnitIdentifier.TypedList, new byte[] { (byte)value }),
|
||||||
|
|
||||||
// [typeof(byte?[])] = (value, con) => (TransmissionTypeIdentifier.TypedList, new byte[] { (byte)value }),
|
// [typeof(byte?[])] = (value, con) => (TransmissionDataUnitIdentifier.TypedList, new byte[] { (byte)value }),
|
||||||
// [typeof(List<bool?>)] = (value, con) => (TransmissionTypeIdentifier.TypedList, new byte[] { (byte)value }),
|
// [typeof(List<bool?>)] = (value, con) => (TransmissionDataUnitIdentifier.TypedList, new byte[] { (byte)value }),
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
internal static (TransmissionTypeIdentifier identifier, byte[])
|
internal static (TransmissionDataUnitIdentifier identifier, byte[])
|
||||||
ComposeInternal(object valueOrSource, Warehouse warehouse, DistributedConnection connection)
|
ComposeInternal(object valueOrSource, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
if (valueOrSource == null)
|
if (valueOrSource == null)
|
||||||
return (TransmissionTypeIdentifier.Null, null);
|
return (TransmissionDataUnitIdentifier.Null, null);
|
||||||
|
|
||||||
var type = valueOrSource.GetType();
|
var type = valueOrSource.GetType();
|
||||||
|
|
||||||
@@ -369,7 +369,7 @@ public static class Codec
|
|||||||
valueOrSource = ((IUserType)valueOrSource).Get();
|
valueOrSource = ((IUserType)valueOrSource).Get();
|
||||||
|
|
||||||
if (valueOrSource == null)
|
if (valueOrSource == null)
|
||||||
return (TransmissionTypeIdentifier.Null, null);
|
return (TransmissionDataUnitIdentifier.Null, null);
|
||||||
|
|
||||||
|
|
||||||
type = valueOrSource.GetType();
|
type = valueOrSource.GetType();
|
||||||
@@ -454,7 +454,7 @@ public static class Codec
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (TransmissionTypeIdentifier.Null, null);
|
return (TransmissionDataUnitIdentifier.Null, null);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -469,7 +469,7 @@ public static class Codec
|
|||||||
public static byte[] Compose(object valueOrSource, Warehouse warehouse, DistributedConnection connection)//, bool prependType = true)
|
public static byte[] Compose(object valueOrSource, Warehouse warehouse, DistributedConnection connection)//, bool prependType = true)
|
||||||
{
|
{
|
||||||
var (hdr, data) = ComposeInternal(valueOrSource, warehouse, connection);
|
var (hdr, data) = ComposeInternal(valueOrSource, warehouse, connection);
|
||||||
return TransmissionType.Compose(hdr, data);
|
return TransmissionDataUnit.Compose(hdr, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsAnonymous(Type type)
|
public static bool IsAnonymous(Type type)
|
||||||
|
@@ -677,16 +677,16 @@ public static class DataDeserializer
|
|||||||
{
|
{
|
||||||
var rt = new List<object>();
|
var rt = new List<object>();
|
||||||
|
|
||||||
//TransmissionTypeIdentifier? previous = null;
|
//TransmissionDataUnitIdentifier? previous = null;
|
||||||
//byte[]? previousUUID = null;
|
//byte[]? previousUUID = null;
|
||||||
|
|
||||||
TransmissionType? previous = null;
|
TransmissionDataUnit? previous = null;
|
||||||
|
|
||||||
while (length > 0)
|
while (length > 0)
|
||||||
{
|
{
|
||||||
var (longLen, dataType) = TransmissionType.Parse(data, offset, (uint)data.Length);
|
var (longLen, dataType) = TransmissionDataUnit.Parse(data, offset, (uint)data.Length);
|
||||||
|
|
||||||
if (dataType.Value.Identifier == TransmissionTypeIdentifier.Same)
|
if (dataType.Value.Identifier == TransmissionDataUnitIdentifier.Same)
|
||||||
{
|
{
|
||||||
// Add UUID
|
// Add UUID
|
||||||
}
|
}
|
||||||
|
@@ -14,108 +14,108 @@ public static class DataSerializer
|
|||||||
{
|
{
|
||||||
public delegate byte[] Serializer(object value);
|
public delegate byte[] Serializer(object value);
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) Int32Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) Int32Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var v = (int)value;
|
var v = (int)value;
|
||||||
var rt = new byte[4];
|
var rt = new byte[4];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((int*)ptr) = v;
|
*((int*)ptr) = v;
|
||||||
return (TransmissionTypeIdentifier.Int32, rt);
|
return (TransmissionDataUnitIdentifier.Int32, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) UInt32Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) UInt32Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var v = (uint)value;
|
var v = (uint)value;
|
||||||
var rt = new byte[4];
|
var rt = new byte[4];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((uint*)ptr) = v;
|
*((uint*)ptr) = v;
|
||||||
return (TransmissionTypeIdentifier.UInt32, rt);
|
return (TransmissionDataUnitIdentifier.UInt32, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) Int16Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) Int16Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var v = (short)value;
|
var v = (short)value;
|
||||||
var rt = new byte[2];
|
var rt = new byte[2];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((short*)ptr) = v;
|
*((short*)ptr) = v;
|
||||||
return (TransmissionTypeIdentifier.Int16, rt);
|
return (TransmissionDataUnitIdentifier.Int16, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) UInt16Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) UInt16Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var v = (ushort)value;
|
var v = (ushort)value;
|
||||||
var rt = new byte[2];
|
var rt = new byte[2];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((ushort*)ptr) = v;
|
*((ushort*)ptr) = v;
|
||||||
return (TransmissionTypeIdentifier.UInt16, rt);
|
return (TransmissionDataUnitIdentifier.UInt16, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) Float32Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) Float32Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var v = (float)value;
|
var v = (float)value;
|
||||||
var rt = new byte[4];
|
var rt = new byte[4];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((float*)ptr) = v;
|
*((float*)ptr) = v;
|
||||||
return (TransmissionTypeIdentifier.Float32, rt);
|
return (TransmissionDataUnitIdentifier.Float32, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) Float64Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) Float64Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var v = (double)value;
|
var v = (double)value;
|
||||||
var rt = new byte[8];
|
var rt = new byte[8];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((double*)ptr) = v;
|
*((double*)ptr) = v;
|
||||||
return (TransmissionTypeIdentifier.Float64, rt);
|
return (TransmissionDataUnitIdentifier.Float64, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) Int64Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) Int64Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var v = (long)value;
|
var v = (long)value;
|
||||||
var rt = new byte[8];
|
var rt = new byte[8];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((long*)ptr) = v;
|
*((long*)ptr) = v;
|
||||||
return (TransmissionTypeIdentifier.Int64, rt);
|
return (TransmissionDataUnitIdentifier.Int64, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) UIn64Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) UIn64Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var v = (ulong)value;
|
var v = (ulong)value;
|
||||||
var rt = new byte[8];
|
var rt = new byte[8];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((ulong*)ptr) = v;
|
*((ulong*)ptr) = v;
|
||||||
return (TransmissionTypeIdentifier.UInt64, rt);
|
return (TransmissionDataUnitIdentifier.UInt64, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) DateTimeComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) DateTimeComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var v = ((DateTime)value).ToUniversalTime().Ticks;
|
var v = ((DateTime)value).ToUniversalTime().Ticks;
|
||||||
var rt = new byte[8];
|
var rt = new byte[8];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((long*)ptr) = v;
|
*((long*)ptr) = v;
|
||||||
return (TransmissionTypeIdentifier.DateTime, rt);
|
return (TransmissionDataUnitIdentifier.DateTime, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) Float128Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) Float128Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var v = (decimal)value;
|
var v = (decimal)value;
|
||||||
var rt = new byte[16];
|
var rt = new byte[16];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((decimal*)ptr) = v;
|
*((decimal*)ptr) = v;
|
||||||
return (TransmissionTypeIdentifier.Decimal128, rt);
|
return (TransmissionDataUnitIdentifier.Decimal128, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) StringComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) StringComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
return (TransmissionTypeIdentifier.String, Encoding.UTF8.GetBytes((string)value));
|
return (TransmissionDataUnitIdentifier.String, Encoding.UTF8.GetBytes((string)value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) EnumComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) EnumComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
|
|
||||||
//var warehouse = connection?.Instance?.Warehouse ?? connection?.Server?.Instance?.Warehouse;
|
//var warehouse = connection?.Instance?.Warehouse ?? connection?.Server?.Instance?.Warehouse;
|
||||||
//if (warehouse == null)
|
//if (warehouse == null)
|
||||||
@@ -128,64 +128,64 @@ public static class DataSerializer
|
|||||||
var ct = template.Constants.FirstOrDefault(x => x.Value.Equals(intVal));
|
var ct = template.Constants.FirstOrDefault(x => x.Value.Equals(intVal));
|
||||||
|
|
||||||
if (ct == null)
|
if (ct == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
|
|
||||||
|
|
||||||
var rt = new List<byte>();
|
var rt = new List<byte>();
|
||||||
rt.AddRange(template.ClassId.Data);
|
rt.AddRange(template.ClassId.Data);
|
||||||
rt.Add(ct.Index);
|
rt.Add(ct.Index);
|
||||||
|
|
||||||
return (TransmissionTypeIdentifier.TypedEnum, rt.ToArray());
|
return (TransmissionDataUnitIdentifier.TypedEnum, rt.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) UInt8Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) UInt8Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
return (TransmissionTypeIdentifier.UInt8, new byte[] { (byte)value });
|
return (TransmissionDataUnitIdentifier.UInt8, new byte[] { (byte)value });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) Int8Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) Int8Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
return (TransmissionTypeIdentifier.Int8, new byte[] { (byte)(sbyte)value });
|
return (TransmissionDataUnitIdentifier.Int8, new byte[] { (byte)(sbyte)value });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) Char8Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) Char8Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
return (TransmissionTypeIdentifier.Char8, new byte[] { (byte)(char)value });
|
return (TransmissionDataUnitIdentifier.Char8, new byte[] { (byte)(char)value });
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) Char16Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) Char16Composer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
|
|
||||||
var v = (char)value;
|
var v = (char)value;
|
||||||
var rt = new byte[2];
|
var rt = new byte[2];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((char*)ptr) = v;
|
*((char*)ptr) = v;
|
||||||
return (TransmissionTypeIdentifier.Char16, rt);
|
return (TransmissionDataUnitIdentifier.Char16, rt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) BoolComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) BoolComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
return ((bool)value ? TransmissionTypeIdentifier.True : TransmissionTypeIdentifier.False, new byte[0]);
|
return ((bool)value ? TransmissionDataUnitIdentifier.True : TransmissionDataUnitIdentifier.False, new byte[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) NotModifiedComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) NotModifiedComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
return (TransmissionTypeIdentifier.NotModified, new byte[0]);
|
return (TransmissionDataUnitIdentifier.NotModified, new byte[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) RawDataComposerFromArray(object value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) RawDataComposerFromArray(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
return (TransmissionTypeIdentifier.RawData, (byte[])value);
|
return (TransmissionDataUnitIdentifier.RawData, (byte[])value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) RawDataComposerFromList(dynamic value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) RawDataComposerFromList(dynamic value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
return (TransmissionTypeIdentifier.RawData, (value as List<byte>).ToArray());
|
return (TransmissionDataUnitIdentifier.RawData, (value as List<byte>).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static (TransmissionTypeIdentifier, byte[]) ListComposerFromArray(dynamic value, DistributedConnection connection)
|
//public static (TransmissionDataUnitIdentifier, byte[]) ListComposerFromArray(dynamic value, DistributedConnection connection)
|
||||||
//{
|
//{
|
||||||
// var rt = new List<byte>();
|
// var rt = new List<byte>();
|
||||||
// var array = (object[])value;
|
// var array = (object[])value;
|
||||||
@@ -193,18 +193,18 @@ public static class DataSerializer
|
|||||||
// for (var i = 0; i < array.Length; i++)
|
// for (var i = 0; i < array.Length; i++)
|
||||||
// rt.AddRange(Codec.Compose(array[i], connection));
|
// rt.AddRange(Codec.Compose(array[i], connection));
|
||||||
|
|
||||||
// return (TransmissionTypeIdentifier.List, rt.ToArray());
|
// return (TransmissionDataUnitIdentifier.List, rt.ToArray());
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) ListComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) ListComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
|
|
||||||
var rt = ArrayComposer((IEnumerable)value, warehouse, connection);
|
var rt = ArrayComposer((IEnumerable)value, warehouse, connection);
|
||||||
|
|
||||||
if (rt == null)
|
if (rt == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
else
|
else
|
||||||
return (TransmissionTypeIdentifier.List, rt);
|
return (TransmissionDataUnitIdentifier.List, rt);
|
||||||
|
|
||||||
|
|
||||||
//var rt = new List<byte>();
|
//var rt = new List<byte>();
|
||||||
@@ -213,16 +213,16 @@ public static class DataSerializer
|
|||||||
//foreach (var o in list)
|
//foreach (var o in list)
|
||||||
// rt.AddRange(Codec.Compose(o, connection));
|
// rt.AddRange(Codec.Compose(o, connection));
|
||||||
|
|
||||||
//return (TransmissionTypeIdentifier.List, rt.ToArray());
|
//return (TransmissionDataUnitIdentifier.List, rt.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) TypedListComposer(IEnumerable value, Type type, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) TypedListComposer(IEnumerable value, Type type, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var composed = ArrayComposer((IEnumerable)value, warehouse, connection);
|
var composed = ArrayComposer((IEnumerable)value, warehouse, connection);
|
||||||
|
|
||||||
if (composed == null)
|
if (composed == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
|
|
||||||
var header = RepresentationType.FromType(type).Compose();
|
var header = RepresentationType.FromType(type).Compose();
|
||||||
|
|
||||||
@@ -231,7 +231,7 @@ public static class DataSerializer
|
|||||||
rt.AddRange(header);
|
rt.AddRange(header);
|
||||||
rt.AddRange(composed);
|
rt.AddRange(composed);
|
||||||
|
|
||||||
return (TransmissionTypeIdentifier.TypedList, rt.ToArray());
|
return (TransmissionDataUnitIdentifier.TypedList, rt.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static byte[] PropertyValueComposer(PropertyValue propertyValue, DistributedConnection connection)//, bool includeAge = true)
|
//public static byte[] PropertyValueComposer(PropertyValue propertyValue, DistributedConnection connection)//, bool includeAge = true)
|
||||||
@@ -245,10 +245,10 @@ public static class DataSerializer
|
|||||||
// .ToArray();
|
// .ToArray();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) PropertyValueArrayComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) PropertyValueArrayComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
|
|
||||||
var rt = new List<byte>();
|
var rt = new List<byte>();
|
||||||
var ar = value as PropertyValue[];
|
var ar = value as PropertyValue[];
|
||||||
@@ -260,13 +260,13 @@ public static class DataSerializer
|
|||||||
rt.AddRange(Codec.Compose(pv.Value, warehouse, connection));
|
rt.AddRange(Codec.Compose(pv.Value, warehouse, connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (TransmissionTypeIdentifier.RawData, rt.ToArray());
|
return (TransmissionDataUnitIdentifier.RawData, rt.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) TypedMapComposer(object value, Type keyType, Type valueType, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) TypedMapComposer(object value, Type keyType, Type valueType, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
|
|
||||||
var kt = RepresentationType.FromType(keyType).Compose();
|
var kt = RepresentationType.FromType(keyType).Compose();
|
||||||
var vt = RepresentationType.FromType(valueType).Compose();
|
var vt = RepresentationType.FromType(valueType).Compose();
|
||||||
@@ -282,12 +282,12 @@ public static class DataSerializer
|
|||||||
rt.AddRange(Codec.Compose(el, warehouse, connection));
|
rt.AddRange(Codec.Compose(el, warehouse, connection));
|
||||||
|
|
||||||
|
|
||||||
return (TransmissionTypeIdentifier.TypedMap, rt.ToArray());
|
return (TransmissionDataUnitIdentifier.TypedMap, rt.ToArray());
|
||||||
}
|
}
|
||||||
public static (TransmissionTypeIdentifier, byte[]) TypedDictionaryComposer(object value, Type keyType, Type valueType, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) TypedDictionaryComposer(object value, Type keyType, Type valueType, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
|
|
||||||
var kt = RepresentationType.FromType(keyType).Compose();
|
var kt = RepresentationType.FromType(keyType).Compose();
|
||||||
var vt = RepresentationType.FromType(valueType).Compose();
|
var vt = RepresentationType.FromType(valueType).Compose();
|
||||||
@@ -310,7 +310,7 @@ public static class DataSerializer
|
|||||||
rt.AddRange(Codec.Compose(el, warehouse, connection));
|
rt.AddRange(Codec.Compose(el, warehouse, connection));
|
||||||
|
|
||||||
|
|
||||||
return (TransmissionTypeIdentifier.TypedMap, rt.ToArray());
|
return (TransmissionDataUnitIdentifier.TypedMap, rt.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] ArrayComposer(IEnumerable value, Warehouse warehouse, DistributedConnection connection)
|
public static byte[] ArrayComposer(IEnumerable value, Warehouse warehouse, DistributedConnection connection)
|
||||||
@@ -320,7 +320,7 @@ public static class DataSerializer
|
|||||||
|
|
||||||
var rt = new List<byte>();
|
var rt = new List<byte>();
|
||||||
|
|
||||||
TransmissionTypeIdentifier? previous = null;
|
TransmissionDataUnitIdentifier? previous = null;
|
||||||
byte[]? previousUUID = null;
|
byte[]? previousUUID = null;
|
||||||
|
|
||||||
foreach (var i in value)
|
foreach (var i in value)
|
||||||
@@ -330,15 +330,15 @@ public static class DataSerializer
|
|||||||
previous = hdr;
|
previous = hdr;
|
||||||
else if (hdr == previous)
|
else if (hdr == previous)
|
||||||
{
|
{
|
||||||
if (hdr == TransmissionTypeIdentifier.Record)
|
if (hdr == TransmissionDataUnitIdentifier.Record)
|
||||||
{
|
{
|
||||||
var newUUID = data.Take(16).ToArray();
|
var newUUID = data.Take(16).ToArray();
|
||||||
// check same uuid
|
// check same uuid
|
||||||
if (newUUID.SequenceEqual(previousUUID))
|
if (newUUID.SequenceEqual(previousUUID))
|
||||||
rt.AddRange(TransmissionType.Compose(TransmissionTypeIdentifier.Same,
|
rt.AddRange(TransmissionDataUnit.Compose(TransmissionDataUnitIdentifier.Same,
|
||||||
data.Skip(16).ToArray()));
|
data.Skip(16).ToArray()));
|
||||||
else
|
else
|
||||||
rt.AddRange(TransmissionType.Compose(hdr, data));
|
rt.AddRange(TransmissionDataUnit.Compose(hdr, data));
|
||||||
|
|
||||||
previous = hdr;
|
previous = hdr;
|
||||||
previousUUID = newUUID;
|
previousUUID = newUUID;
|
||||||
@@ -351,32 +351,32 @@ public static class DataSerializer
|
|||||||
return rt.ToArray();
|
return rt.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) ResourceListComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) ResourceListComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
|
|
||||||
|
|
||||||
return (TransmissionTypeIdentifier.ResourceList, ArrayComposer((IEnumerable)value, warehouse, connection));
|
return (TransmissionDataUnitIdentifier.ResourceList, ArrayComposer((IEnumerable)value, warehouse, connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) RecordListComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) RecordListComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
|
|
||||||
|
|
||||||
return (TransmissionTypeIdentifier.RecordList, ArrayComposer((IEnumerable)value, warehouse, connection));
|
return (TransmissionDataUnitIdentifier.RecordList, ArrayComposer((IEnumerable)value, warehouse, connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) ResourceComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) ResourceComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var resource = (IResource)value;
|
var resource = (IResource)value;
|
||||||
|
|
||||||
if (resource.Instance == null || resource.Instance.IsDestroyed)
|
if (resource.Instance == null || resource.Instance.IsDestroyed)
|
||||||
{
|
{
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Codec.IsLocalResource(resource, connection))
|
if (Codec.IsLocalResource(resource, connection))
|
||||||
@@ -384,21 +384,21 @@ public static class DataSerializer
|
|||||||
var rid = (resource as DistributedResource).DistributedResourceInstanceId;
|
var rid = (resource as DistributedResource).DistributedResourceInstanceId;
|
||||||
|
|
||||||
if (rid <= 0xFF)
|
if (rid <= 0xFF)
|
||||||
return (TransmissionTypeIdentifier.LocalResource8, new byte[] { (byte)rid });
|
return (TransmissionDataUnitIdentifier.LocalResource8, new byte[] { (byte)rid });
|
||||||
else if (rid <= 0xFFFF)
|
else if (rid <= 0xFFFF)
|
||||||
{
|
{
|
||||||
var rt = new byte[2];
|
var rt = new byte[2];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((ushort*)ptr) = (ushort)rid;
|
*((ushort*)ptr) = (ushort)rid;
|
||||||
|
|
||||||
return (TransmissionTypeIdentifier.LocalResource16, rt);
|
return (TransmissionDataUnitIdentifier.LocalResource16, rt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var rt = new byte[4];
|
var rt = new byte[4];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((uint*)ptr) = rid;
|
*((uint*)ptr) = rid;
|
||||||
return (TransmissionTypeIdentifier.LocalResource32, rt);
|
return (TransmissionDataUnitIdentifier.LocalResource32, rt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -410,29 +410,29 @@ public static class DataSerializer
|
|||||||
var rid = resource.Instance.Id;
|
var rid = resource.Instance.Id;
|
||||||
|
|
||||||
if (rid <= 0xFF)
|
if (rid <= 0xFF)
|
||||||
return (TransmissionTypeIdentifier.RemoteResource8, new byte[] { (byte)rid });
|
return (TransmissionDataUnitIdentifier.RemoteResource8, new byte[] { (byte)rid });
|
||||||
else if (rid <= 0xFFFF)
|
else if (rid <= 0xFFFF)
|
||||||
{
|
{
|
||||||
var rt = new byte[2];
|
var rt = new byte[2];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((ushort*)ptr) = (ushort)rid;
|
*((ushort*)ptr) = (ushort)rid;
|
||||||
|
|
||||||
return (TransmissionTypeIdentifier.RemoteResource16, rt);
|
return (TransmissionDataUnitIdentifier.RemoteResource16, rt);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var rt = new byte[4];
|
var rt = new byte[4];
|
||||||
fixed (byte* ptr = rt)
|
fixed (byte* ptr = rt)
|
||||||
*((uint*)ptr) = rid;
|
*((uint*)ptr) = rid;
|
||||||
return (TransmissionTypeIdentifier.RemoteResource32, rt);
|
return (TransmissionDataUnitIdentifier.RemoteResource32, rt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) MapComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) MapComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
|
|
||||||
var rt = new List<byte>();
|
var rt = new List<byte>();
|
||||||
var map = (IMap)value;
|
var map = (IMap)value;
|
||||||
@@ -440,16 +440,16 @@ public static class DataSerializer
|
|||||||
foreach (var el in map.Serialize())
|
foreach (var el in map.Serialize())
|
||||||
rt.AddRange(Codec.Compose(el, warehouse, connection));
|
rt.AddRange(Codec.Compose(el, warehouse, connection));
|
||||||
|
|
||||||
return (TransmissionTypeIdentifier.Map, rt.ToArray());
|
return (TransmissionDataUnitIdentifier.Map, rt.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) UUIDComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) UUIDComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
return (TransmissionTypeIdentifier.UUID, ((UUID)value).Data);
|
return (TransmissionDataUnitIdentifier.UUID, ((UUID)value).Data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static unsafe (TransmissionTypeIdentifier, byte[]) RecordComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static unsafe (TransmissionDataUnitIdentifier, byte[]) RecordComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
var rt = new List<byte>();// BinaryList();
|
var rt = new List<byte>();// BinaryList();
|
||||||
var record = (IRecord)value;
|
var record = (IRecord)value;
|
||||||
@@ -465,7 +465,7 @@ public static class DataSerializer
|
|||||||
rt.AddRange(Codec.Compose(propValue, warehouse, connection));
|
rt.AddRange(Codec.Compose(propValue, warehouse, connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
return (TransmissionTypeIdentifier.Record, rt.ToArray());
|
return (TransmissionDataUnitIdentifier.Record, rt.ToArray());
|
||||||
}
|
}
|
||||||
public static byte[] HistoryComposer(KeyList<PropertyTemplate, PropertyValue[]> history, Warehouse warehouse,
|
public static byte[] HistoryComposer(KeyList<PropertyTemplate, PropertyValue[]> history, Warehouse warehouse,
|
||||||
DistributedConnection connection, bool prependLength = false)
|
DistributedConnection connection, bool prependLength = false)
|
||||||
@@ -483,10 +483,10 @@ public static class DataSerializer
|
|||||||
return rt.ToArray();
|
return rt.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static (TransmissionTypeIdentifier, byte[]) TupleComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
public static (TransmissionDataUnitIdentifier, byte[]) TupleComposer(object value, Warehouse warehouse, DistributedConnection connection)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
|
|
||||||
var rt = new List<byte>();
|
var rt = new List<byte>();
|
||||||
|
|
||||||
@@ -502,11 +502,11 @@ public static class DataSerializer
|
|||||||
var composed = ArrayComposer(list, warehouse, connection);
|
var composed = ArrayComposer(list, warehouse, connection);
|
||||||
|
|
||||||
if (composed == null)
|
if (composed == null)
|
||||||
return (TransmissionTypeIdentifier.Null, new byte[0]);
|
return (TransmissionDataUnitIdentifier.Null, new byte[0]);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
rt.AddRange(composed);
|
rt.AddRange(composed);
|
||||||
return (TransmissionTypeIdentifier.TypedTuple, rt.ToArray());
|
return (TransmissionDataUnitIdentifier.TypedTuple, rt.ToArray());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -76,42 +76,42 @@ namespace Esiur.Data
|
|||||||
RepresentationTypeIdentifier.TypedResource
|
RepresentationTypeIdentifier.TypedResource
|
||||||
};
|
};
|
||||||
|
|
||||||
static Map<TransmissionTypeIdentifier, RepresentationTypeIdentifier> typesMap = new Map<TransmissionTypeIdentifier, RepresentationTypeIdentifier>()
|
static Map<TransmissionDataUnitIdentifier, RepresentationTypeIdentifier> typesMap = new Map<TransmissionDataUnitIdentifier, RepresentationTypeIdentifier>()
|
||||||
{
|
{
|
||||||
[TransmissionTypeIdentifier.UInt8] = RepresentationTypeIdentifier.UInt8,
|
[TransmissionDataUnitIdentifier.UInt8] = RepresentationTypeIdentifier.UInt8,
|
||||||
[TransmissionTypeIdentifier.Int8] = RepresentationTypeIdentifier.Int8,
|
[TransmissionDataUnitIdentifier.Int8] = RepresentationTypeIdentifier.Int8,
|
||||||
[TransmissionTypeIdentifier.UInt16] = RepresentationTypeIdentifier.UInt16,
|
[TransmissionDataUnitIdentifier.UInt16] = RepresentationTypeIdentifier.UInt16,
|
||||||
[TransmissionTypeIdentifier.Int16] = RepresentationTypeIdentifier.Int16,
|
[TransmissionDataUnitIdentifier.Int16] = RepresentationTypeIdentifier.Int16,
|
||||||
[TransmissionTypeIdentifier.UInt32] = RepresentationTypeIdentifier.UInt32,
|
[TransmissionDataUnitIdentifier.UInt32] = RepresentationTypeIdentifier.UInt32,
|
||||||
[TransmissionTypeIdentifier.Int32] = RepresentationTypeIdentifier.Int32,
|
[TransmissionDataUnitIdentifier.Int32] = RepresentationTypeIdentifier.Int32,
|
||||||
[TransmissionTypeIdentifier.UInt64] = RepresentationTypeIdentifier.UInt64,
|
[TransmissionDataUnitIdentifier.UInt64] = RepresentationTypeIdentifier.UInt64,
|
||||||
[TransmissionTypeIdentifier.Int64] = RepresentationTypeIdentifier.Int64,
|
[TransmissionDataUnitIdentifier.Int64] = RepresentationTypeIdentifier.Int64,
|
||||||
[TransmissionTypeIdentifier.UInt128] = RepresentationTypeIdentifier.UInt128,
|
[TransmissionDataUnitIdentifier.UInt128] = RepresentationTypeIdentifier.UInt128,
|
||||||
[TransmissionTypeIdentifier.Int128] = RepresentationTypeIdentifier.Int128,
|
[TransmissionDataUnitIdentifier.Int128] = RepresentationTypeIdentifier.Int128,
|
||||||
[TransmissionTypeIdentifier.Char8] = RepresentationTypeIdentifier.Char,
|
[TransmissionDataUnitIdentifier.Char8] = RepresentationTypeIdentifier.Char,
|
||||||
[TransmissionTypeIdentifier.DateTime] = RepresentationTypeIdentifier.DateTime,
|
[TransmissionDataUnitIdentifier.DateTime] = RepresentationTypeIdentifier.DateTime,
|
||||||
[TransmissionTypeIdentifier.Float32] = RepresentationTypeIdentifier.Float32,
|
[TransmissionDataUnitIdentifier.Float32] = RepresentationTypeIdentifier.Float32,
|
||||||
[TransmissionTypeIdentifier.Float64] = RepresentationTypeIdentifier.Float64,
|
[TransmissionDataUnitIdentifier.Float64] = RepresentationTypeIdentifier.Float64,
|
||||||
[TransmissionTypeIdentifier.Decimal128] = RepresentationTypeIdentifier.Decimal,
|
[TransmissionDataUnitIdentifier.Decimal128] = RepresentationTypeIdentifier.Decimal,
|
||||||
[TransmissionTypeIdentifier.False] = RepresentationTypeIdentifier.Bool,
|
[TransmissionDataUnitIdentifier.False] = RepresentationTypeIdentifier.Bool,
|
||||||
[TransmissionTypeIdentifier.True] = RepresentationTypeIdentifier.Bool,
|
[TransmissionDataUnitIdentifier.True] = RepresentationTypeIdentifier.Bool,
|
||||||
[TransmissionTypeIdentifier.Map] = RepresentationTypeIdentifier.Map,
|
[TransmissionDataUnitIdentifier.Map] = RepresentationTypeIdentifier.Map,
|
||||||
[TransmissionTypeIdentifier.List] = RepresentationTypeIdentifier.List,
|
[TransmissionDataUnitIdentifier.List] = RepresentationTypeIdentifier.List,
|
||||||
[TransmissionTypeIdentifier.RawData] = RepresentationTypeIdentifier.RawData,
|
[TransmissionDataUnitIdentifier.RawData] = RepresentationTypeIdentifier.RawData,
|
||||||
[TransmissionTypeIdentifier.Record] = RepresentationTypeIdentifier.Record,
|
[TransmissionDataUnitIdentifier.Record] = RepresentationTypeIdentifier.Record,
|
||||||
[TransmissionTypeIdentifier.String] = RepresentationTypeIdentifier.String,
|
[TransmissionDataUnitIdentifier.String] = RepresentationTypeIdentifier.String,
|
||||||
};
|
};
|
||||||
|
|
||||||
public bool IsCompatible(TransmissionType tdu)
|
public bool IsCompatible(TransmissionDataUnit tdu)
|
||||||
{
|
{
|
||||||
var tru = typesMap[tdu.Identifier];
|
var tru = typesMap[tdu.Identifier];
|
||||||
|
|
||||||
if (tru != Identifier)
|
if (tru != Identifier)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (tdu.Class == TransmissionTypeClass.Typed)
|
if (tdu.Class == TransmissionDataUnitClass.Typed)
|
||||||
{
|
{
|
||||||
if (tdu.Identifier == TransmissionTypeIdentifier.)
|
if (tdu.Identifier == TransmissionDataUnitIdentifier.)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
272
Esiur/Data/TransmissionDataUnit.cs
Normal file
272
Esiur/Data/TransmissionDataUnit.cs
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
using Esiur.Net.IIP;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Esiur.Data;
|
||||||
|
|
||||||
|
|
||||||
|
public struct TransmissionDataUnit
|
||||||
|
{
|
||||||
|
public TransmissionDataUnitIdentifier Identifier;
|
||||||
|
public int Index;
|
||||||
|
public TransmissionDataUnitClass Class;
|
||||||
|
public uint Offset;
|
||||||
|
public ulong ContentLength;
|
||||||
|
public byte Exponent;
|
||||||
|
public byte[] Data;
|
||||||
|
|
||||||
|
public TransmissionDataUnit(byte[] data, TransmissionDataUnitIdentifier identifier,
|
||||||
|
TransmissionDataUnitClass cls, int index, uint offset,
|
||||||
|
ulong contentLength, byte exponent = 0)
|
||||||
|
{
|
||||||
|
Identifier = identifier;
|
||||||
|
Index = index;
|
||||||
|
Class = cls;
|
||||||
|
Offset=offset;
|
||||||
|
ContentLength = contentLength;
|
||||||
|
Exponent = exponent;
|
||||||
|
Data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] GetTypeMetadata()
|
||||||
|
{
|
||||||
|
if (Class != TransmissionDataUnitClass.Typed)
|
||||||
|
throw new Exception("Class has no metadata.");
|
||||||
|
|
||||||
|
var size = Data[Offset];
|
||||||
|
return Data.Clip(Offset + 1, size);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] Compose(TransmissionDataUnitIdentifier identifier, byte[] data, byte[] typeMetadata = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (data == null || data.Length == 0)
|
||||||
|
return new byte[] { (byte)identifier };
|
||||||
|
|
||||||
|
var cls = (TransmissionDataUnitClass)((int)identifier >> 6);
|
||||||
|
if (cls == TransmissionDataUnitClass.Fixed)
|
||||||
|
{
|
||||||
|
return DC.Combine(new byte[] { (byte)identifier }, 0, 1, data, 0, (uint)data.Length);
|
||||||
|
}
|
||||||
|
else if (cls == TransmissionDataUnitClass.Dynamic)
|
||||||
|
{
|
||||||
|
var len = (ulong)data.LongLength;
|
||||||
|
|
||||||
|
if (len == 0)
|
||||||
|
{
|
||||||
|
return new byte[1] { (byte) identifier };
|
||||||
|
}
|
||||||
|
else if (len <= 0xFF)
|
||||||
|
{
|
||||||
|
var rt = new byte[2 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x8);
|
||||||
|
rt[1] = (byte)len;
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 2, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
else if (len <= 0xFF_FF)
|
||||||
|
{
|
||||||
|
var rt = new byte[3 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x10);
|
||||||
|
rt[1] = (byte)((len >> 8) & 0xFF);
|
||||||
|
rt[2] = (byte)(len & 0xFF);
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 3, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
else if (len <= 0xFF_FF_FF)
|
||||||
|
{
|
||||||
|
var rt = new byte[4 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x18);
|
||||||
|
rt[1] = (byte)((len >> 16) & 0xFF);
|
||||||
|
rt[2] = (byte)((len >> 8) & 0xFF);
|
||||||
|
rt[3] = (byte)(len & 0xFF);
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 4, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
else if (len <= 0xFF_FF_FF_FF)
|
||||||
|
{
|
||||||
|
var rt = new byte[5 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x20);
|
||||||
|
rt[1] = (byte)((len >> 24) & 0xFF);
|
||||||
|
rt[2] = (byte)((len >> 16) & 0xFF);
|
||||||
|
rt[3] = (byte)((len >> 8) & 0xFF);
|
||||||
|
rt[4] = (byte)(len & 0xFF);
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 5, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
else if (len <= 0xFF_FF_FF_FF_FF)
|
||||||
|
{
|
||||||
|
var rt = new byte[6 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x28);
|
||||||
|
rt[1] = (byte)((len >> 32) & 0xFF);
|
||||||
|
rt[2] = (byte)((len >> 24) & 0xFF);
|
||||||
|
rt[3] = (byte)((len >> 16) & 0xFF);
|
||||||
|
rt[4] = (byte)((len >> 8) & 0xFF);
|
||||||
|
rt[5] = (byte)(len & 0xFF);
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 6, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
else if (len <= 0xFF_FF_FF_FF_FF_FF)
|
||||||
|
{
|
||||||
|
var rt = new byte[7 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x30);
|
||||||
|
rt[1] = (byte)((len >> 40) & 0xFF);
|
||||||
|
rt[2] = (byte)((len >> 32) & 0xFF);
|
||||||
|
rt[3] = (byte)((len >> 24) & 0xFF);
|
||||||
|
rt[4] = (byte)((len >> 16) & 0xFF);
|
||||||
|
rt[5] = (byte)((len >> 8) & 0xFF);
|
||||||
|
rt[6] = (byte)(len & 0xFF);
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 7, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
else //if (len <= 0xFF_FF_FF_FF_FF_FF_FF)
|
||||||
|
{
|
||||||
|
var rt = new byte[8 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x38);
|
||||||
|
rt[1] = (byte)((len >> 48) & 0xFF);
|
||||||
|
rt[2] = (byte)((len >> 40) & 0xFF);
|
||||||
|
rt[3] = (byte)((len >> 32) & 0xFF);
|
||||||
|
rt[4] = (byte)((len >> 24) & 0xFF);
|
||||||
|
rt[5] = (byte)((len >> 16) & 0xFF);
|
||||||
|
rt[6] = (byte)((len >> 8) & 0xFF);
|
||||||
|
rt[7] = (byte)(len & 0xFF);
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 8, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (cls == TransmissionDataUnitClass.Typed)
|
||||||
|
{
|
||||||
|
|
||||||
|
var len = 1 + (ulong)typeMetadata.LongLength + (ulong)data.LongLength;
|
||||||
|
|
||||||
|
if (len == 0)
|
||||||
|
{
|
||||||
|
return new byte[1] { (byte)identifier };
|
||||||
|
}
|
||||||
|
else if (len <= 0xFF)
|
||||||
|
{
|
||||||
|
var rt = new byte[2 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x8);
|
||||||
|
rt[1] = (byte)len;
|
||||||
|
|
||||||
|
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 2, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
else if (len <= 0xFF_FF)
|
||||||
|
{
|
||||||
|
var rt = new byte[3 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x10);
|
||||||
|
rt[1] = (byte)((len >> 8) & 0xFF);
|
||||||
|
rt[2] = (byte)(len & 0xFF);
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 3, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
else if (len <= 0xFF_FF_FF)
|
||||||
|
{
|
||||||
|
var rt = new byte[4 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x18);
|
||||||
|
rt[1] = (byte)((len >> 16) & 0xFF);
|
||||||
|
rt[2] = (byte)((len >> 8) & 0xFF);
|
||||||
|
rt[3] = (byte)(len & 0xFF);
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 4, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
else if (len <= 0xFF_FF_FF_FF)
|
||||||
|
{
|
||||||
|
var rt = new byte[5 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x20);
|
||||||
|
rt[1] = (byte)((len >> 24) & 0xFF);
|
||||||
|
rt[2] = (byte)((len >> 16) & 0xFF);
|
||||||
|
rt[3] = (byte)((len >> 8) & 0xFF);
|
||||||
|
rt[4] = (byte)(len & 0xFF);
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 5, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
else if (len <= 0xFF_FF_FF_FF_FF)
|
||||||
|
{
|
||||||
|
var rt = new byte[6 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x28);
|
||||||
|
rt[1] = (byte)((len >> 32) & 0xFF);
|
||||||
|
rt[2] = (byte)((len >> 24) & 0xFF);
|
||||||
|
rt[3] = (byte)((len >> 16) & 0xFF);
|
||||||
|
rt[4] = (byte)((len >> 8) & 0xFF);
|
||||||
|
rt[5] = (byte)(len & 0xFF);
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 6, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
else if (len <= 0xFF_FF_FF_FF_FF_FF)
|
||||||
|
{
|
||||||
|
var rt = new byte[7 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x30);
|
||||||
|
rt[1] = (byte)((len >> 40) & 0xFF);
|
||||||
|
rt[2] = (byte)((len >> 32) & 0xFF);
|
||||||
|
rt[3] = (byte)((len >> 24) & 0xFF);
|
||||||
|
rt[4] = (byte)((len >> 16) & 0xFF);
|
||||||
|
rt[5] = (byte)((len >> 8) & 0xFF);
|
||||||
|
rt[6] = (byte)(len & 0xFF);
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 7, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
else //if (len <= 0xFF_FF_FF_FF_FF_FF_FF)
|
||||||
|
{
|
||||||
|
var rt = new byte[8 + len];
|
||||||
|
rt[0] = (byte)((byte)identifier | 0x38);
|
||||||
|
rt[1] = (byte)((len >> 48) & 0xFF);
|
||||||
|
rt[2] = (byte)((len >> 40) & 0xFF);
|
||||||
|
rt[3] = (byte)((len >> 32) & 0xFF);
|
||||||
|
rt[4] = (byte)((len >> 24) & 0xFF);
|
||||||
|
rt[5] = (byte)((len >> 16) & 0xFF);
|
||||||
|
rt[6] = (byte)((len >> 8) & 0xFF);
|
||||||
|
rt[7] = (byte)(len & 0xFF);
|
||||||
|
Buffer.BlockCopy(data, 0, rt, 8, (int)len);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static (ulong, TransmissionDataUnit?) Parse(byte[] data, uint offset, uint ends)
|
||||||
|
{
|
||||||
|
var h = data[offset++];
|
||||||
|
|
||||||
|
var cls = (TransmissionDataUnitClass)(h >> 6);
|
||||||
|
|
||||||
|
if (cls == TransmissionDataUnitClass.Fixed)
|
||||||
|
{
|
||||||
|
var exp = (h & 0x38) >> 3;
|
||||||
|
|
||||||
|
if (exp == 0)
|
||||||
|
return (1, new TransmissionDataUnit(data, (TransmissionDataUnitIdentifier)h, cls, h & 0x7, 0, (byte)exp));
|
||||||
|
|
||||||
|
ulong cl = (ulong)(1 << (exp -1));
|
||||||
|
|
||||||
|
if (ends - offset < cl)
|
||||||
|
return (cl - (ends - offset), null);
|
||||||
|
|
||||||
|
//offset += (uint)cl;
|
||||||
|
|
||||||
|
return (1 + cl, new TransmissionDataUnit(data, (TransmissionDataUnitIdentifier)h, cls, h & 0x7, offset, cl, (byte)exp));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ulong cll = (ulong)(h >> 3) & 0x7;
|
||||||
|
|
||||||
|
if (ends - offset < cll)
|
||||||
|
return (cll - (ends - offset), null);
|
||||||
|
|
||||||
|
ulong cl = 0;
|
||||||
|
|
||||||
|
for (uint i = 0; i < cll; i++)
|
||||||
|
cl = cl << 8 | data[offset++];
|
||||||
|
|
||||||
|
if (ends - offset < cl)
|
||||||
|
return (cl - (ends - offset), null);
|
||||||
|
|
||||||
|
|
||||||
|
return (1 + cl + cll, new TransmissionDataUnit(data, (TransmissionDataUnitIdentifier)(h & 0xC7), cls, h & 0x7, offset, cl));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
14
Esiur/Data/TransmissionDataUnitClass.cs
Normal file
14
Esiur/Data/TransmissionDataUnitClass.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Esiur.Data
|
||||||
|
{
|
||||||
|
public enum TransmissionDataUnitClass
|
||||||
|
{
|
||||||
|
Fixed = 0x0,
|
||||||
|
Dynamic = 0x1,
|
||||||
|
Typed = 0x2,
|
||||||
|
Extension = 0x3
|
||||||
|
}
|
||||||
|
}
|
63
Esiur/Data/TransmissionDataUnitIdentifier.cs
Normal file
63
Esiur/Data/TransmissionDataUnitIdentifier.cs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace Esiur.Data
|
||||||
|
{
|
||||||
|
public enum TransmissionDataUnitIdentifier
|
||||||
|
{
|
||||||
|
Null = 0x0,
|
||||||
|
False = 0x1,
|
||||||
|
True = 0x2,
|
||||||
|
NotModified = 0x3,
|
||||||
|
UInt8 = 0x8,
|
||||||
|
Int8 = 0x9,
|
||||||
|
Char8 = 0xA,
|
||||||
|
LocalResource8 = 0xB,
|
||||||
|
RemoteResource8 = 0xC,
|
||||||
|
LocalProcedure8 = 0xD,
|
||||||
|
RemoteProcedure8 = 0xE,
|
||||||
|
UInt16 = 0x10,
|
||||||
|
Int16 = 0x11,
|
||||||
|
Char16 = 0x12,
|
||||||
|
LocalResource16 = 0x13,
|
||||||
|
RemoteResource16 = 0x14,
|
||||||
|
LocalProcedure16 = 0x15,
|
||||||
|
RemoteProcedure16 = 0x16,
|
||||||
|
UInt32 = 0x18,
|
||||||
|
Int32 = 0x19,
|
||||||
|
Float32 = 0x1A,
|
||||||
|
LocalResource32 = 0x1B,
|
||||||
|
RemoteResource32 = 0x1C,
|
||||||
|
LocalProcedure32 = 0x1D,
|
||||||
|
RemoteProcedure32 = 0x1E,
|
||||||
|
UInt64 = 0x20,
|
||||||
|
Int64 = 0x21,
|
||||||
|
Float64 = 0x22,
|
||||||
|
DateTime = 0x23,
|
||||||
|
UInt128 = 0x28,
|
||||||
|
Int128 = 0x29,
|
||||||
|
Decimal128 = 0x2A,
|
||||||
|
UUID = 0x2B,
|
||||||
|
|
||||||
|
RawData = 0x40,
|
||||||
|
String = 0x41,
|
||||||
|
List = 0x42,
|
||||||
|
ResourceList = 0x43,
|
||||||
|
RecordList = 0x44,
|
||||||
|
Map = 0x45,
|
||||||
|
MapList = 0x46,
|
||||||
|
|
||||||
|
Record = 0x80,
|
||||||
|
TypedList = 0x81,
|
||||||
|
TypedMap = 0x82,
|
||||||
|
TypedTuple = 0x83,
|
||||||
|
TypedEnum = 0x84,
|
||||||
|
TypedConstant = 0x85,
|
||||||
|
|
||||||
|
ResourceLink = 0xC0,
|
||||||
|
|
||||||
|
Same = 0xFF
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@@ -1,261 +0,0 @@
|
|||||||
using Esiur.Net.IIP;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace Esiur.Data;
|
|
||||||
|
|
||||||
public enum TransmissionTypeIdentifier : byte
|
|
||||||
{
|
|
||||||
Null = 0x0,
|
|
||||||
False = 0x1,
|
|
||||||
True = 0x2,
|
|
||||||
NotModified = 0x3,
|
|
||||||
UInt8 = 0x8,
|
|
||||||
Int8 = 0x9,
|
|
||||||
Char8 = 0xA,
|
|
||||||
LocalResource8 = 0xB,
|
|
||||||
RemoteResource8 = 0xC,
|
|
||||||
LocalProcedure8 = 0xD,
|
|
||||||
RemoteProcedure8 = 0xE,
|
|
||||||
UInt16 = 0x10,
|
|
||||||
Int16 = 0x11,
|
|
||||||
Char16 = 0x12,
|
|
||||||
LocalResource16 = 0x13,
|
|
||||||
RemoteResource16 = 0x14,
|
|
||||||
LocalProcedure16 = 0x15,
|
|
||||||
RemoteProcedure16 = 0x16,
|
|
||||||
UInt32 = 0x18,
|
|
||||||
Int32 = 0x19,
|
|
||||||
Float32 = 0x1A,
|
|
||||||
LocalResource32 = 0x1B,
|
|
||||||
RemoteResource32 = 0x1C,
|
|
||||||
LocalProcedure32 = 0x1D,
|
|
||||||
RemoteProcedure32 = 0x1E,
|
|
||||||
UInt64 = 0x20,
|
|
||||||
Int64 = 0x21,
|
|
||||||
Float64 = 0x22,
|
|
||||||
DateTime = 0x23,
|
|
||||||
UInt128 = 0x28,
|
|
||||||
Int128 = 0x29,
|
|
||||||
Decimal128 = 0x2A,
|
|
||||||
UUID = 0x2B,
|
|
||||||
|
|
||||||
RawData = 0x40,
|
|
||||||
String = 0x41,
|
|
||||||
List = 0x42,
|
|
||||||
ResourceList = 0x43,
|
|
||||||
RecordList = 0x44,
|
|
||||||
Map = 0x45,
|
|
||||||
MapList = 0x46,
|
|
||||||
|
|
||||||
Record = 0x80,
|
|
||||||
TypedList = 0x81,
|
|
||||||
TypedMap = 0x82,
|
|
||||||
TypedTuple = 0x83,
|
|
||||||
TypedEnum = 0x84,
|
|
||||||
TypedConstant = 0x85,
|
|
||||||
|
|
||||||
ResourceLink = 0xC0,
|
|
||||||
|
|
||||||
Same = 0xFF
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum TransmissionTypeClass
|
|
||||||
{
|
|
||||||
Fixed = 0,
|
|
||||||
Dynamic = 1,
|
|
||||||
Typed = 2
|
|
||||||
}
|
|
||||||
|
|
||||||
public struct TransmissionType
|
|
||||||
{
|
|
||||||
public TransmissionTypeIdentifier Identifier;
|
|
||||||
public int Index;
|
|
||||||
public TransmissionTypeClass Class;
|
|
||||||
public uint Offset;
|
|
||||||
public ulong ContentLength;
|
|
||||||
public byte Exponent;
|
|
||||||
|
|
||||||
|
|
||||||
public TransmissionType(TransmissionTypeIdentifier identifier, TransmissionTypeClass cls, int index, uint offset, ulong contentLength, byte exponent = 0)
|
|
||||||
{
|
|
||||||
Identifier = identifier;
|
|
||||||
Index = index;
|
|
||||||
Class = cls;
|
|
||||||
Offset=offset;
|
|
||||||
ContentLength = contentLength;
|
|
||||||
Exponent = exponent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static byte[] Compose(TransmissionTypeIdentifier identifier, byte[] data)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (data == null || data.Length == 0)
|
|
||||||
return new byte[] { (byte)identifier };
|
|
||||||
|
|
||||||
var cls = (TransmissionTypeClass)((int)identifier >> 6);
|
|
||||||
if (cls == TransmissionTypeClass.Fixed)
|
|
||||||
{
|
|
||||||
return DC.Combine(new byte[] { (byte)identifier }, 0, 1, data, 0, (uint)data.Length);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var len = (ulong)data.LongLength;
|
|
||||||
|
|
||||||
if (len == 0)
|
|
||||||
{
|
|
||||||
return new byte[1] { (byte) identifier };
|
|
||||||
}
|
|
||||||
else if (len <= 0xFF)
|
|
||||||
{
|
|
||||||
var rt = new byte[2 + len];
|
|
||||||
rt[0] = (byte)((byte)identifier | 0x8);
|
|
||||||
rt[1] = (byte)len;
|
|
||||||
Buffer.BlockCopy(data, 0, rt, 2, (int)len);
|
|
||||||
return rt;
|
|
||||||
}
|
|
||||||
else if (len <= 0xFF_FF)
|
|
||||||
{
|
|
||||||
var rt = new byte[3 + len];
|
|
||||||
rt[0] = (byte)((byte)identifier | 0x10);
|
|
||||||
rt[1] = (byte)((len >> 8) & 0xFF);
|
|
||||||
rt[2] = (byte)(len & 0xFF);
|
|
||||||
Buffer.BlockCopy(data, 0, rt, 3, (int)len);
|
|
||||||
return rt;
|
|
||||||
}
|
|
||||||
else if (len <= 0xFF_FF_FF)
|
|
||||||
{
|
|
||||||
var rt = new byte[4 + len];
|
|
||||||
rt[0] = (byte)((byte)identifier | 0x18);
|
|
||||||
rt[1] = (byte)((len >> 16) & 0xFF);
|
|
||||||
rt[2] = (byte)((len >> 8) & 0xFF);
|
|
||||||
rt[3] = (byte)(len & 0xFF);
|
|
||||||
Buffer.BlockCopy(data, 0, rt, 4, (int)len);
|
|
||||||
return rt;
|
|
||||||
}
|
|
||||||
else if (len <= 0xFF_FF_FF_FF)
|
|
||||||
{
|
|
||||||
var rt = new byte[5 + len];
|
|
||||||
rt[0] = (byte)((byte)identifier | 0x20);
|
|
||||||
rt[1] = (byte)((len >> 24) & 0xFF);
|
|
||||||
rt[2] = (byte)((len >> 16) & 0xFF);
|
|
||||||
rt[3] = (byte)((len >> 8) & 0xFF);
|
|
||||||
rt[4] = (byte)(len & 0xFF);
|
|
||||||
Buffer.BlockCopy(data, 0, rt, 5, (int)len);
|
|
||||||
return rt;
|
|
||||||
}
|
|
||||||
else if (len <= 0xFF_FF_FF_FF_FF)
|
|
||||||
{
|
|
||||||
var rt = new byte[6 + len];
|
|
||||||
rt[0] = (byte)((byte)identifier | 0x28);
|
|
||||||
rt[1] = (byte)((len >> 32) & 0xFF);
|
|
||||||
rt[2] = (byte)((len >> 24) & 0xFF);
|
|
||||||
rt[3] = (byte)((len >> 16) & 0xFF);
|
|
||||||
rt[4] = (byte)((len >> 8) & 0xFF);
|
|
||||||
rt[5] = (byte)(len & 0xFF);
|
|
||||||
Buffer.BlockCopy(data, 0, rt, 6, (int)len);
|
|
||||||
return rt;
|
|
||||||
}
|
|
||||||
else if (len <= 0xFF_FF_FF_FF_FF_FF)
|
|
||||||
{
|
|
||||||
var rt = new byte[7 + len];
|
|
||||||
rt[0] = (byte)((byte)identifier | 0x30);
|
|
||||||
rt[1] = (byte)((len >> 40) & 0xFF);
|
|
||||||
rt[2] = (byte)((len >> 32) & 0xFF);
|
|
||||||
rt[3] = (byte)((len >> 24) & 0xFF);
|
|
||||||
rt[4] = (byte)((len >> 16) & 0xFF);
|
|
||||||
rt[5] = (byte)((len >> 8) & 0xFF);
|
|
||||||
rt[6] = (byte)(len & 0xFF);
|
|
||||||
Buffer.BlockCopy(data, 0, rt, 7, (int)len);
|
|
||||||
return rt;
|
|
||||||
}
|
|
||||||
else //if (len <= 0xFF_FF_FF_FF_FF_FF_FF)
|
|
||||||
{
|
|
||||||
var rt = new byte[8 + len];
|
|
||||||
rt[0] = (byte)((byte)identifier | 0x38);
|
|
||||||
rt[1] = (byte)((len >> 48) & 0xFF);
|
|
||||||
rt[2] = (byte)((len >> 40) & 0xFF);
|
|
||||||
rt[3] = (byte)((len >> 32) & 0xFF);
|
|
||||||
rt[4] = (byte)((len >> 24) & 0xFF);
|
|
||||||
rt[5] = (byte)((len >> 16) & 0xFF);
|
|
||||||
rt[6] = (byte)((len >> 8) & 0xFF);
|
|
||||||
rt[7] = (byte)(len & 0xFF);
|
|
||||||
Buffer.BlockCopy(data, 0, rt, 8, (int)len);
|
|
||||||
return rt;
|
|
||||||
}
|
|
||||||
//else // if (len <= 0xFF_FF_FF_FF_FF_FF_FF_FF)
|
|
||||||
//{
|
|
||||||
// var rt = new byte[9 + len];
|
|
||||||
// rt[0] = (byte)((byte)identifier | 0x8);
|
|
||||||
// rt[1] = (byte)((len >> 56) & 0xFF);
|
|
||||||
// rt[2] = (byte)((len >> 48) & 0xFF);
|
|
||||||
// rt[3] = (byte)((len >> 40) & 0xFF);
|
|
||||||
// rt[4] = (byte)((len >> 32) & 0xFF);
|
|
||||||
// rt[5] = (byte)((len >> 24) & 0xFF);
|
|
||||||
// rt[6] = (byte)((len >> 16) & 0xFF);
|
|
||||||
// rt[7] = (byte)((len >> 8) & 0xFF);
|
|
||||||
// rt[8] = (byte)(len & 0xFF);
|
|
||||||
// Buffer.BlockCopy(data, 0, rt, 9, (int)len);
|
|
||||||
// return rt;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
// // add length
|
|
||||||
// int bytes = 1;
|
|
||||||
//for (var i = 56; i > 0; i -= 8, bytes++)
|
|
||||||
// if (len <= (0xFF_FF_FF_FF_FF_FF_FF_FF >> i))
|
|
||||||
// break;
|
|
||||||
|
|
||||||
//var rt = new byte[1 + bytes + data.Length];
|
|
||||||
//rt[0] = (byte)((byte)identifier | (bytes << 3));
|
|
||||||
|
|
||||||
//for (var i = 1; i <= bytes; i++)
|
|
||||||
// rt[i] = data.LongLength >> i * 8;
|
|
||||||
|
|
||||||
//Buffer.BlockCopy(data, 0, rt, 1 + bytes, data.Length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static (ulong, TransmissionType?) Parse(byte[] data, uint offset, uint ends)
|
|
||||||
{
|
|
||||||
var h = data[offset++];
|
|
||||||
|
|
||||||
var cls = (TransmissionTypeClass)(h >> 6);
|
|
||||||
|
|
||||||
if (cls == TransmissionTypeClass.Fixed)
|
|
||||||
{
|
|
||||||
var exp = (h & 0x38) >> 3;
|
|
||||||
|
|
||||||
if (exp == 0)
|
|
||||||
return (1, new TransmissionType((TransmissionTypeIdentifier)h, cls, h & 0x7, 0, (byte)exp));
|
|
||||||
|
|
||||||
ulong cl = (ulong)(1 << (exp -1));
|
|
||||||
|
|
||||||
if (ends - offset < cl)
|
|
||||||
return (cl - (ends - offset), null);
|
|
||||||
|
|
||||||
//offset += (uint)cl;
|
|
||||||
|
|
||||||
return (1 + cl, new TransmissionType((TransmissionTypeIdentifier)h, cls, h & 0x7, offset, cl, (byte)exp));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ulong cll = (ulong)(h >> 3) & 0x7;
|
|
||||||
|
|
||||||
if (ends - offset < cll)
|
|
||||||
return (cll - (ends - offset), null);
|
|
||||||
|
|
||||||
ulong cl = 0;
|
|
||||||
|
|
||||||
for (uint i = 0; i < cll; i++)
|
|
||||||
cl = cl << 8 | data[offset++];
|
|
||||||
|
|
||||||
if (ends - offset < cl)
|
|
||||||
return (cl - (ends - offset), null);
|
|
||||||
|
|
||||||
return (1 + cl + cll, new TransmissionType((TransmissionTypeIdentifier)(h & 0xC7), cls, h & 0x7, offset, cl));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@@ -51,9 +51,9 @@ public partial class DistributedConnection : NetworkConnection, IStore
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public delegate void ProtocolGeneralHandler(DistributedConnection connection, TransmissionType dataType, byte[] data);
|
public delegate void ProtocolGeneralHandler(DistributedConnection connection, TransmissionDataUnit dataType, byte[] data);
|
||||||
|
|
||||||
public delegate void ProtocolRequestReplyHandler(DistributedConnection connection, uint callbackId, TransmissionType dataType, byte[] data);
|
public delegate void ProtocolRequestReplyHandler(DistributedConnection connection, uint callbackId, TransmissionDataUnit dataType, byte[] data);
|
||||||
|
|
||||||
// Delegates
|
// Delegates
|
||||||
public delegate void ReadyEvent(DistributedConnection sender);
|
public delegate void ReadyEvent(DistributedConnection sender);
|
||||||
|
@@ -262,7 +262,7 @@ partial class DistributedConnection
|
|||||||
SendReply(IIPPacketReply.Chunk, callbackId, chunk);
|
SendReply(IIPPacketReply.Chunk, callbackId, chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPReplyCompleted(uint callbackId, TransmissionType dataType, byte[] data)
|
void IIPReplyCompleted(uint callbackId, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var req = requests.Take(callbackId);
|
var req = requests.Take(callbackId);
|
||||||
|
|
||||||
@@ -286,12 +286,12 @@ partial class DistributedConnection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPExtensionAction(byte actionId, TransmissionType? dataType, byte[] data)
|
void IIPExtensionAction(byte actionId, TransmissionDataUnit? dataType, byte[] data)
|
||||||
{
|
{
|
||||||
// nothing is supported now
|
// nothing is supported now
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPReplyPropagated(uint callbackId, TransmissionType dataType, byte[] data)
|
void IIPReplyPropagated(uint callbackId, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var req = requests[callbackId];
|
var req = requests[callbackId];
|
||||||
|
|
||||||
@@ -315,7 +315,7 @@ partial class DistributedConnection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPReplyError(uint callbackId, TransmissionType dataType, byte[] data, ErrorType type)
|
void IIPReplyError(uint callbackId, TransmissionDataUnit dataType, byte[] data, ErrorType type)
|
||||||
{
|
{
|
||||||
var req = requests.Take(callbackId);
|
var req = requests.Take(callbackId);
|
||||||
|
|
||||||
@@ -334,7 +334,7 @@ partial class DistributedConnection
|
|||||||
req.TriggerError(new AsyncException(type, errorCode, errorMsg));
|
req.TriggerError(new AsyncException(type, errorCode, errorMsg));
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPReplyProgress(uint callbackId, TransmissionType dataType, byte[] data)
|
void IIPReplyProgress(uint callbackId, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var req = requests[callbackId];
|
var req = requests[callbackId];
|
||||||
|
|
||||||
@@ -353,7 +353,7 @@ partial class DistributedConnection
|
|||||||
req.TriggerProgress(ProgressType.Execution, current, total);
|
req.TriggerProgress(ProgressType.Execution, current, total);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPReplyWarning(uint callbackId, TransmissionType dataType, byte[] data)
|
void IIPReplyWarning(uint callbackId, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var req = requests[callbackId];
|
var req = requests[callbackId];
|
||||||
|
|
||||||
@@ -374,7 +374,7 @@ partial class DistributedConnection
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void IIPReplyChunk(uint callbackId, TransmissionType dataType, byte[] data)
|
void IIPReplyChunk(uint callbackId, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var req = requests[callbackId];
|
var req = requests[callbackId];
|
||||||
|
|
||||||
@@ -389,16 +389,16 @@ partial class DistributedConnection
|
|||||||
req.TriggerChunk(parsed);
|
req.TriggerChunk(parsed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPNotificationResourceReassigned(TransmissionType dataType, byte[] data)
|
void IIPNotificationResourceReassigned(TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
// uint resourceId, uint newResourceId
|
// uint resourceId, uint newResourceId
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPNotificationResourceMoved(TransmissionType dataType, byte[] data) { }
|
void IIPNotificationResourceMoved(TransmissionDataUnit dataType, byte[] data) { }
|
||||||
|
|
||||||
void IIPNotificationSystemFailure(TransmissionType dataType, byte[] data) { }
|
void IIPNotificationSystemFailure(TransmissionDataUnit dataType, byte[] data) { }
|
||||||
|
|
||||||
void IIPNotificationResourceDestroyed(TransmissionType dataType, byte[] data)
|
void IIPNotificationResourceDestroyed(TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var (size, rt) = Codec.ParseSync(data, dataType.Offset, Instance.Warehouse, dataType);
|
var (size, rt) = Codec.ParseSync(data, dataType.Offset, Instance.Warehouse, dataType);
|
||||||
|
|
||||||
@@ -429,7 +429,7 @@ partial class DistributedConnection
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPNotificationPropertyModified(TransmissionType dataType, byte[] data)
|
void IIPNotificationPropertyModified(TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
// resourceId, index, value
|
// resourceId, index, value
|
||||||
var (valueOffset, valueSize, args) =
|
var (valueOffset, valueSize, args) =
|
||||||
@@ -468,7 +468,7 @@ partial class DistributedConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IIPNotificationEventOccurred(TransmissionType dataType, byte[] data)
|
void IIPNotificationEventOccurred(TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
// resourceId, index, value
|
// resourceId, index, value
|
||||||
var (valueOffset, valueSize, args) =
|
var (valueOffset, valueSize, args) =
|
||||||
@@ -517,7 +517,7 @@ partial class DistributedConnection
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestAttachResource(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestAttachResource(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
|
|
||||||
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
||||||
@@ -572,7 +572,7 @@ partial class DistributedConnection
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestReattachResource(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestReattachResource(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
// resourceId, index, value
|
// resourceId, index, value
|
||||||
var (valueOffset, valueSize, args) =
|
var (valueOffset, valueSize, args) =
|
||||||
@@ -630,7 +630,7 @@ partial class DistributedConnection
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestDetachResource(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestDetachResource(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
|
|
||||||
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
||||||
@@ -661,7 +661,7 @@ partial class DistributedConnection
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestCreateResource(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestCreateResource(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var (_, parsed) = Codec.ParseAsync(data, 0, this, null, dataType);
|
var (_, parsed) = Codec.ParseAsync(data, 0, this, null, dataType);
|
||||||
|
|
||||||
@@ -722,7 +722,7 @@ partial class DistributedConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IIPRequestDeleteResource(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestDeleteResource(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
|
|
||||||
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
||||||
@@ -751,7 +751,7 @@ partial class DistributedConnection
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestMoveResource(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestMoveResource(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
|
|
||||||
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
||||||
@@ -790,12 +790,12 @@ partial class DistributedConnection
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void IIPRequestToken(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestToken(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
// @TODO: To be implemented
|
// @TODO: To be implemented
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestLinkTemplates(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestLinkTemplates(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
||||||
|
|
||||||
@@ -828,7 +828,7 @@ partial class DistributedConnection
|
|||||||
Instance.Warehouse.Query(resourceLink).Then(queryCallback);
|
Instance.Warehouse.Query(resourceLink).Then(queryCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestTemplateFromClassName(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestTemplateFromClassName(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
||||||
|
|
||||||
@@ -847,7 +847,7 @@ partial class DistributedConnection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestTemplateFromClassId(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestTemplateFromClassId(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
|
|
||||||
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
||||||
@@ -869,7 +869,7 @@ partial class DistributedConnection
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void IIPRequestTemplateFromResourceId(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestTemplateFromResourceId(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
|
|
||||||
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
var (_, value) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
||||||
@@ -892,7 +892,7 @@ partial class DistributedConnection
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void IIPRequestGetResourceIdByLink(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestGetResourceIdByLink(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var (_, parsed) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
var (_, parsed) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
||||||
var resourceLink = (string)parsed;
|
var resourceLink = (string)parsed;
|
||||||
@@ -920,7 +920,7 @@ partial class DistributedConnection
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestQueryResources(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestQueryResources(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var (_, parsed) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
var (_, parsed) = Codec.ParseSync(data, 0, Instance.Warehouse, dataType);
|
||||||
|
|
||||||
@@ -978,7 +978,7 @@ partial class DistributedConnection
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IIPRequestProcedureCall(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestProcedureCall(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
||||||
dataType.ContentLength, Instance.Warehouse, 1);
|
dataType.ContentLength, Instance.Warehouse, 1);
|
||||||
@@ -1038,7 +1038,7 @@ partial class DistributedConnection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestStaticCall(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestStaticCall(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
||||||
dataType.ContentLength, Instance.Warehouse, 2);
|
dataType.ContentLength, Instance.Warehouse, 2);
|
||||||
@@ -1115,7 +1115,7 @@ partial class DistributedConnection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestInvokeFunction(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestInvokeFunction(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
||||||
dataType.ContentLength, Instance.Warehouse, 2);
|
dataType.ContentLength, Instance.Warehouse, 2);
|
||||||
@@ -1371,7 +1371,7 @@ partial class DistributedConnection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestSubscribe(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestSubscribe(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
|
|
||||||
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
||||||
@@ -1430,7 +1430,7 @@ partial class DistributedConnection
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void IIPRequestUnsubscribe(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestUnsubscribe(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
|
|
||||||
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
||||||
@@ -1491,7 +1491,7 @@ partial class DistributedConnection
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void IIPRequestSetProperty(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestSetProperty(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
|
|
||||||
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
||||||
@@ -2056,7 +2056,7 @@ partial class DistributedConnection
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void IIPRequestKeepAlive(uint callback, TransmissionType dataType, byte[] data)
|
void IIPRequestKeepAlive(uint callback, TransmissionDataUnit dataType, byte[] data)
|
||||||
{
|
{
|
||||||
|
|
||||||
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
var (offset, length, args) = DataDeserializer.LimitedCountListParser(data, dataType.Offset,
|
||||||
|
@@ -136,7 +136,7 @@ public class IIPAuthPacket : Packet
|
|||||||
set;
|
set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TransmissionType? DataType
|
public TransmissionDataUnit? DataType
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
set;
|
set;
|
||||||
@@ -188,7 +188,7 @@ public class IIPAuthPacket : Packet
|
|||||||
if (NotEnough(offset, ends, 1))
|
if (NotEnough(offset, ends, 1))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
(var size, DataType) = TransmissionType.Parse(data, offset, ends);
|
(var size, DataType) = TransmissionDataUnit.Parse(data, offset, ends);
|
||||||
|
|
||||||
if (DataType == null)
|
if (DataType == null)
|
||||||
return -(int)size;
|
return -(int)size;
|
||||||
@@ -208,7 +208,7 @@ public class IIPAuthPacket : Packet
|
|||||||
if (NotEnough(offset, ends, 1))
|
if (NotEnough(offset, ends, 1))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
(var size, DataType) = TransmissionType.Parse(data, offset, ends);
|
(var size, DataType) = TransmissionDataUnit.Parse(data, offset, ends);
|
||||||
|
|
||||||
if (DataType == null)
|
if (DataType == null)
|
||||||
return -(int)size;
|
return -(int)size;
|
||||||
@@ -280,7 +280,7 @@ public class IIPAuthPacket : Packet
|
|||||||
Reference = data.GetUInt32(offset, Endian.Little);
|
Reference = data.GetUInt32(offset, Endian.Little);
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
|
||||||
(var size, DataType) = TransmissionType.Parse(data, offset, ends);
|
(var size, DataType) = TransmissionDataUnit.Parse(data, offset, ends);
|
||||||
|
|
||||||
if (DataType == null)
|
if (DataType == null)
|
||||||
return -(int)size;
|
return -(int)size;
|
||||||
@@ -445,7 +445,7 @@ public class IIPAuthPacket : Packet
|
|||||||
if (NotEnough(offset, ends, 1))
|
if (NotEnough(offset, ends, 1))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
(var size, DataType) = TransmissionType.Parse(data, offset, ends);
|
(var size, DataType) = TransmissionDataUnit.Parse(data, offset, ends);
|
||||||
|
|
||||||
if (DataType == null)
|
if (DataType == null)
|
||||||
return -(int)size;
|
return -(int)size;
|
||||||
|
@@ -44,7 +44,7 @@ class IIPPacket : Packet
|
|||||||
|
|
||||||
public byte Extension { get; set; }
|
public byte Extension { get; set; }
|
||||||
|
|
||||||
public TransmissionType? DataType { get; set; }
|
public TransmissionDataUnit? DataType { get; set; }
|
||||||
|
|
||||||
|
|
||||||
private uint dataLengthNeeded;
|
private uint dataLengthNeeded;
|
||||||
@@ -124,7 +124,7 @@ class IIPPacket : Packet
|
|||||||
if (NotEnough(offset, ends, 1))
|
if (NotEnough(offset, ends, 1))
|
||||||
return -dataLengthNeeded;
|
return -dataLengthNeeded;
|
||||||
|
|
||||||
(var size, DataType) = TransmissionType.Parse(data, offset, ends);
|
(var size, DataType) = TransmissionDataUnit.Parse(data, offset, ends);
|
||||||
|
|
||||||
if (DataType == null)
|
if (DataType == null)
|
||||||
return -(int)size;
|
return -(int)size;
|
||||||
|
Reference in New Issue
Block a user