diff --git a/Libraries/Esiur/Core/AsyncReply.cs b/Libraries/Esiur/Core/AsyncReply.cs
index d2eb82f..30dc518 100644
--- a/Libraries/Esiur/Core/AsyncReply.cs
+++ b/Libraries/Esiur/Core/AsyncReply.cs
@@ -91,7 +91,7 @@ public class AsyncReply
}
//int timeoutMilliseconds = 0;
- public AsyncReply Timeout(int milliseconds, Action callback = null)
+ public void Timeout(int milliseconds, Action callback = null)
{
//timeoutMilliseconds = milliseconds;
@@ -107,7 +107,6 @@ public class AsyncReply
}
});
- return this;
}
public object Wait(int millisecondsTimeout)
@@ -236,7 +235,7 @@ public class AsyncReply
return this;
}
- public AsyncReply Trigger(object result)
+ public void Trigger(object result)
{
lock (asyncLock)
{
@@ -245,13 +244,13 @@ public class AsyncReply
//timeout?.Dispose();
if (exception != null)
- return this;
+ return;
//if (Debug)
// Console.WriteLine($"AsyncReply: {Id} Trigger");
if (resultReady)
- return this;
+ return;
this.result = result;
@@ -269,15 +268,15 @@ public class AsyncReply
}
- return this;
+ return;
}
- public AsyncReply TriggerError(Exception exception)
+ public void TriggerError(Exception exception)
{
//timeout?.Dispose();
if (resultReady)
- return this;
+ return;
if (exception is AsyncException)
this.exception = exception as AsyncException;
@@ -297,10 +296,9 @@ public class AsyncReply
mutex?.Set();
- return this;
}
- public AsyncReply TriggerProgress(ProgressType type, uint value, uint max)
+ public void TriggerProgress(ProgressType type, uint value, uint max)
{
//timeout?.Dispose();
@@ -308,10 +306,10 @@ public class AsyncReply
foreach (var cb in progressCallbacks)
cb(type, value, max);
- return this;
+ return;
}
- public AsyncReply TriggerWarning(byte level, string message)
+ public void TriggerWarning(byte level, string message)
{
//timeout?.Dispose();
@@ -319,11 +317,11 @@ public class AsyncReply
foreach (var cb in warningCallbacks)
cb(level, message);
- return this;
+ return ;
}
- public AsyncReply TriggerPropagation(object value)
+ public void TriggerPropagation(object value)
{
//timeout?.Dispose();
@@ -331,12 +329,12 @@ public class AsyncReply
foreach (var cb in propagationCallbacks)
cb(value);
- return this;
+ return;
}
- public AsyncReply TriggerChunk(object value)
+ public void TriggerChunk(object value)
{
//timeout?.Dispose();
@@ -347,7 +345,6 @@ public class AsyncReply
cb(value);
- return this;
}
public AsyncAwaiter GetAwaiter()
diff --git a/Libraries/Esiur/Data/Codec.cs b/Libraries/Esiur/Data/Codec.cs
index 913082e..a9e0dba 100644
--- a/Libraries/Esiur/Data/Codec.cs
+++ b/Libraries/Esiur/Data/Codec.cs
@@ -100,12 +100,7 @@ public static class Codec
static AsyncParser[] TypedAsyncParsers = new AsyncParser[]
{
- DataDeserializer.RecordParserAsync,
- DataDeserializer.TypedListParserAsync,
- DataDeserializer.TypedMapParserAsync,
- DataDeserializer.TupleParserAsync,
- DataDeserializer.EnumParserAsync,
- DataDeserializer.ConstantParserAsync,
+ DataDeserializer.TypedParserAsync,
};
static AsyncParser[] ExtendedAsyncParsers = new AsyncParser[]
@@ -170,12 +165,13 @@ public static class Codec
static SyncParser[] TypedParsers = new SyncParser[]
{
- DataDeserializer.RecordParser,
- DataDeserializer.TypedListParser,
- DataDeserializer.TypedMapParser,
- DataDeserializer.TupleParser,
- DataDeserializer.EnumParser,
- DataDeserializer.ConstantParser,
+ DataDeserializer.TypedParser,
+ //DataDeserializer.RecordParser,
+ //DataDeserializer.TypedListParser,
+ //DataDeserializer.TypedMapParser,
+ //DataDeserializer.TupleParser,
+ //DataDeserializer.EnumParser,
+ //DataDeserializer.ConstantParser,
};
static SyncParser[] ExtendedParsers = new SyncParser[]
@@ -192,81 +188,197 @@ public static class Codec
/// EpConnection is required in case a structure in the array holds items at the other end.
/// DataType, in case the data is not prepended with DataType
/// Value
- public static (uint, object) ParseAsync(byte[] data, uint offset, EpConnection connection, uint[] requestSequence)
+ public static AsyncReply> ParseAsync(byte[] data, uint offset, EpConnection connection, uint[] requestSequence)
{
+ var rt = new AsyncReply>();
- var tdu = ParsedTdu.Parse(data, offset, (uint)data.Length);
+ ParsedTdu.ParseAsync(data, offset, (uint)data.Length, connection).Then(tdu =>
+ {
+ if (tdu.Class == TduClass.Invalid)
+ throw new NullReferenceException("DataType can't be parsed.");
- if (tdu.Class == TduClass.Invalid)
- throw new NullReferenceException("DataType can't be parsed.");
+ object result;
- if (tdu.Class == TduClass.Fixed)
- {
- return ((uint)tdu.TotalLength, FixedAsyncParsers[tdu.Exponent][tdu.Index](tdu, connection, requestSequence));
- }
- else if (tdu.Class == TduClass.Dynamic)
- {
- return ((uint)tdu.TotalLength, DynamicAsyncParsers[tdu.Index](tdu, connection, requestSequence));
- }
- else if (tdu.Class == TduClass.Typed)
- {
- return ((uint)tdu.TotalLength, TypedAsyncParsers[tdu.Index](tdu, connection, requestSequence));
- }
- else // if (tt.Class == TDUClass.Extension)
- {
- return ((uint)tdu.TotalLength, ExtendedAsyncParsers[tdu.Index](tdu, connection, requestSequence));
+ if (tdu.Class == TduClass.Fixed)
+ {
+ result = FixedAsyncParsers[tdu.Exponent][tdu.Index](tdu, connection, requestSequence);
+
+ }
+ else if (tdu.Class == TduClass.Dynamic)
+ {
+ result = DynamicAsyncParsers[tdu.Index](tdu, connection, requestSequence);
+ }
+ else if (tdu.Class == TduClass.Typed)
+ {
+ result = TypedAsyncParsers[tdu.Index](tdu, connection, requestSequence);
+ }
+ else // if (tt.Class == TDUClass.Extension)
+ {
+ result = ExtendedAsyncParsers[tdu.Index](tdu, connection, requestSequence);
+ }
+
+ if (result is AsyncReply asyncReply)
+ {
+ asyncReply.Then(value =>
+ {
+ rt.Trigger(new ParseResult