Execution module solved

This commit is contained in:
2025-05-04 20:14:46 +03:00
parent 8f97e5b0a6
commit 149ea07569
11 changed files with 23 additions and 557 deletions
-125
View File
@@ -1,125 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using mROA.Cbor;
namespace mROA.Test;
public class CborTest
{
private ComplexTestObject _complexTestObject;
private IContextualSerializationToolKit _serializationToolKit;
private BasicCollectionElement _basicCollectionElement;
[SetUp]
public void Setup()
{
_basicCollectionElement = new() { A = 567565, B = "test text", C = 2.781f };
_complexTestObject = new ComplexTestObject
{
IntValue = 123,
DoubleValue = 3.14159,
StringValue = "abc",
EnumValue = TestEnum.X,
CollectionElements =
[
_basicCollectionElement,
new BasicCollectionElement { A = 8_000_000, B = "Fi number", C = 1.618f }
],
IntArray = [1, 4, 8, 16, 87]
};
_serializationToolKit = new CborSerializationToolkit();
}
[Test]
public void BasicOnly()
{
var value = 123;
var data = _serializationToolKit.Serialize(value, null);
var deserialize = _serializationToolKit.Deserialize<int>(data, null);
Assert.That(value, Is.EqualTo(deserialize));
}
[Test]
public void ComplexFlat()
{
var value = _basicCollectionElement;
var data = _serializationToolKit.Serialize(value, null);
var deserialize = _serializationToolKit.Deserialize<BasicCollectionElement>(data, null);
Assert.That(value, Is.EqualTo(deserialize));
}
[Test]
public void ComplexFull()
{
var value = _complexTestObject;
var data = _serializationToolKit.Serialize(value, null);
var deserialize = _serializationToolKit.Deserialize<ComplexTestObject>(data, null);
Assert.That(value, Is.EqualTo(deserialize));
}
public void SharedObject()
{
}
private class ComplexTestObject
{
public int IntValue { get; set; }
public double DoubleValue { get; set; }
public string StringValue { get; set; }
public TestEnum EnumValue { get; set; }
public int[] IntArray { get; set; }
public List<BasicCollectionElement> CollectionElements { get; set; }
protected bool Equals(ComplexTestObject other)
{
return IntValue == other.IntValue && DoubleValue.Equals(other.DoubleValue) && StringValue == other.StringValue && IntArray.SequenceEqual(other.IntArray) && CollectionElements.SequenceEqual(other.CollectionElements);
}
public override bool Equals(object? obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((ComplexTestObject)obj);
}
public override int GetHashCode()
{
return HashCode.Combine(IntValue, DoubleValue, StringValue, IntArray, CollectionElements);
}
}
private class BasicCollectionElement
{
public int A { get; set; }
public string B { get; set; }
public float C { get; set; }
protected bool Equals(BasicCollectionElement other)
{
return A == other.A && B == other.B && C.Equals(other.C);
}
public override bool Equals(object? obj)
{
if (obj is null) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != GetType()) return false;
return Equals((BasicCollectionElement)obj);
}
public override int GetHashCode()
{
return HashCode.Combine(A, B, C);
}
}
public enum TestEnum
{
X = -5, Y, Z
}
}
-92
View File
@@ -1,92 +0,0 @@
// using System.Net;
// using System.Net.Sockets;
// using System.Reflection;
// using mROA.Abstract;
// using mROA.Codegen;
// using Example.Shared;
// using mROA.Implementation;
//
// namespace mROA.Test;
//
// public class FrontendFinalTest
// {
// private StreamBasedInteractionModule _interactionModule;
// private StreamBasedFrontendInteractionModule _frontendInteractionModule;
// private JsonFrontendSerialisationModule _frontendSerialisationModule;
// private ISerialisationModule _serialisationModule;
// private IExecuteModule _executeModule;
// private IMethodRepository _methodRepository;
// private IContextRepository _contextRepository;
// bool isTestNotFinished = true;
// private IContextRepository _frontendContextRepository;
//
// [SetUp]
// public void Setup()
// {
// _methodRepository = new CoCodegenMethodRepository();
// var repo2 = new ContextRepository();
// repo2.FillSingletons(typeof(ITestController).Assembly);
// _contextRepository = repo2;
//
// _interactionModule = new StreamBasedInteractionModule();
//
// _serialisationModule = new JsonSerialisationModule();
//
// _executeModule = new BasicExecutionModule();
//
// IInjectableModule[] backendModules =
// [_methodRepository, _contextRepository, _interactionModule, _serialisationModule, _executeModule];
//
// foreach (var backendModule in backendModules)
// foreach (var injection in backendModules)
// backendModule.Inject(injection);
//
// _frontendInteractionModule = new StreamBasedFrontendInteractionModule();
// _frontendSerialisationModule = new JsonFrontendSerialisationModule();
// _frontendContextRepository = new FrontendContextRepository();
//
// IInjectableModule[] frontendModules =
// [_frontendInteractionModule, _frontendSerialisationModule, _frontendContextRepository];
//
// foreach (var backendModule in frontendModules)
// foreach (var injection in frontendModules)
// backendModule.Inject(injection);
//
// Task.Run(() =>
// {
// TcpListener listener = new TcpListener(IPAddress.Loopback, 4567);
// listener.Start();
//
// var stream = listener.AcceptTcpClient().GetStream();
//
// Console.WriteLine("Client connected");
//
// _interactionModule.RegisterSourse(stream);
//
// while (isTestNotFinished) ;
// });
//
// var tcpClient = new TcpClient();
// tcpClient.Connect(IPAddress.Loopback, 4567);
// _frontendInteractionModule.ServerStream = tcpClient.GetStream();
// }
//
// [Test]
// public void CallTest()
// {
// var singleton = _frontendContextRepository.GetSingleObject(typeof(ITestController)) as ITestController;
//
// var x = singleton.B();
// Console.WriteLine(x);
// }
//
// [Test]
// public void TransmittionTest()
// {
// var singleton = _frontendContextRepository.GetSingleObject(typeof(ITestController)) as ITestController;
//
// var next = singleton.SharedObjectTransmitionTest().Value;
// var parameter = singleton.GetTestParameter().Value;
// var x = next.Parametrized(new TestParameter { A = 100, LinkedObject = new(parameter!) });
// }
// }
-79
View File
@@ -1,79 +0,0 @@
using System;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using mROA.Implementation;
namespace mROA.Test
{
public class NextGenTest
{
private TcpListener _listener;
private ChannelInteractionModule _interactionModuleA;
private ChannelInteractionModule _interactionModuleB;
private Guid[] guids = [Guid.NewGuid(), Guid.NewGuid(), Guid.NewGuid()];
[SetUp]
public void Setup()
{
_listener = new TcpListener(IPAddress.Loopback, 4567);
_interactionModuleA = new ChannelInteractionModule();
_interactionModuleA.Inject(new JsonSerializationToolkit());
_interactionModuleB = new ChannelInteractionModule();
_interactionModuleB.Inject(new JsonSerializationToolkit());
}
[Test]
public void MultithreadedTest()
{
Task.Run(() =>
{
_listener.Start();
// _interactionModuleB.BaseStream = _listener.AcceptTcpClient().GetStream();
foreach (var guid in guids)
{
_interactionModuleB.PostMessageAsync(new NetworkMessageHeader { Id = guid, Data = "Hello user"u8.ToArray() });
}
});
var client = new TcpClient();
client.Connect(IPAddress.Loopback, 4567);
// _interactionModuleA.BaseStream = client.GetStream();
var tasks = guids.Select(ReadStream);
Task.WaitAll(tasks.ToArray());
Assert.Pass();
}
private async Task ReadStream(Guid current)
{
var msg = await _interactionModuleA.GetNextMessageReceiving();
Console.WriteLine(
$"{Environment.CurrentManagedThreadId} Received message: {Encoding.Default.GetString(new JsonSerializationToolkit().Serialize(msg))}");
while (msg.Id != current)
{
msg = await _interactionModuleA.GetNextMessageReceiving();
Console.WriteLine(
$"{Environment.CurrentManagedThreadId} Received message: {Encoding.Default.GetString(new JsonSerializationToolkit().Serialize(msg))}");
}
Console.WriteLine($"{Environment.CurrentManagedThreadId} Good message received");
}
[TearDown]
public void TearDown()
{
_listener.Stop();
_listener.Dispose();
_interactionModuleA.Dispose();
_interactionModuleB.Dispose();
}
}
}
-65
View File
@@ -1,65 +0,0 @@
// using System.Net;
// using System.Net.Sockets;
// using System.Text.Json;
// using mROA.Implementation;
//
// namespace mROA.Test;
//
// public class StreamTest
// {
// private StreamBasedInteractionModule _interactionModule;
// private StreamBasedFrontendInteractionModule _frontendInteractionModule;
// private JsonFrontendSerialisationModule _frontendSerialisationModule;
// private ISerialisationModule _serialisationModule;
// private IExecuteModule _executeModule;
// bool isTestNotFinished = true;
//
// [SetUp]
// public void Setup()
// {
// _interactionModule = new StreamBasedInteractionModule();
//
// _serialisationModule = new JsonSerialisationModule(_interactionModule, new MockMethodRepository());
//
// _executeModule = new MockExecModule();
// _serialisationModule.SetExecuteModule(_executeModule);
//
// _frontendInteractionModule = new StreamBasedFrontendInteractionModule();
// _frontendSerialisationModule = new JsonFrontendSerialisationModule(_frontendInteractionModule);
//
// Task.Run(() =>
// {
// TcpListener listener = new TcpListener(IPAddress.Loopback, 4567);
// listener.Start();
//
// var stream = listener.AcceptTcpClient().GetStream();
//
// Console.WriteLine("Client connected");
//
// _interactionModule.RegisterSourse(stream);
//
// while (isTestNotFinished) ;
// });
// }
//
// [Test]
// public void StreamingTest()
// {
// var tcpClient = new TcpClient();
// tcpClient.Connect(IPAddress.Loopback, 4567);
// _frontendInteractionModule.ServerStream = tcpClient.GetStream();
//
// var req = new DefaultCallRequest { CommandId = 1, ObjectId = -1 };
// _frontendSerialisationModule.PostCallRequest(req);
// var res = ((JsonElement)_frontendSerialisationModule
// .GetNextCommandExecution<FinalCommandExecution>(req.CallRequestId).GetAwaiter().GetResult().Result!)
// .Deserialize<MockResult>();
// isTestNotFinished = false;
// Assert.That(res.A == "wqer" && res.B == 5);
// }
//
// [Test]
// public void RemoteObjectTest()
// {
// }
// }
-26
View File
@@ -1,26 +0,0 @@
using mROA.Implementation;
namespace mROA.Test;
public class UnSOization
{
private ComplexObjectIdentifier _uoi;
[SetUp]
public void Setup()
{
_uoi = new ComplexObjectIdentifier
{
ContextId = -123, OwnerId = 123
};
}
[Test]
public void FlatTest()
{
var flat = _uoi.Flat;
var next = new ComplexObjectIdentifier { Flat = flat };
Assert.That(_uoi, Is.EqualTo(next));
}
}
-154
View File
@@ -1,154 +0,0 @@
// using System.Diagnostics;
// using System.Reflection;
// using System.Text;
// using System.Text.Json;
// using Example.Shared;
// using mROA.Implementation;
// using Newtonsoft.Json;
// using JsonSerializer = System.Text.Json.JsonSerializer;
//
// namespace mROA.Test;
//
// public class Tests
// {
// private ProgramlyInteractionChanel _interactionModule;
// private ISerialisationModule _serialisationModule;
// private IExecuteModule _executeModule;
// private IMethodRepository _methodRepository;
// private IContextRepository _contextRepository;
//
// private ITestController _testController;
//
// [SetUp]
// public void Setup()
// {
// _interactionModule = new ProgramlyInteractionChanel();
// var repo = new MethodRepository();
// repo.CollectForAssembly(Assembly.GetExecutingAssembly());
// _methodRepository = repo;
// var repo2 = new ContextRepository();
// repo2.FillSingletons(Assembly.GetExecutingAssembly());
// _contextRepository = repo2;
// _serialisationModule = new JsonSerialisationModule(_interactionModule, _methodRepository);
//
// _executeModule = new LaunchReadyExecutionModule(_methodRepository, _serialisationModule, _contextRepository);
// TransmissionConfig.DefaultContextRepository = _contextRepository;
// }
//
// [Test]
// public void CommandPipelineTest()
// {
// var sw = Stopwatch.StartNew();
//
// _interactionModule.PassCommand(132, """
// {
// "RequestTypeId": 0,
// "CommandId": 2
// }
// """u8.ToArray());
// Assert.Pass(_interactionModule.OutputBuffer.Last());
// }
//
// [Test]
// public void CommandPipelineTestAsync()
// {
// var sw = Stopwatch.StartNew();
// _interactionModule.PassCommand(132, """
// {
// "RequestTypeId": 0,
// "CommandId": 3
// }
// """u8.ToArray());
// while (_interactionModule.OutputBuffer.Count != 2) ;
//
// Assert.Pass(_interactionModule.OutputBuffer.Last());
// }
//
// [Test]
// public void MethodRegistrationTest()
// {
// var repo = new MethodRepository();
// repo.CollectForAssembly(Assembly.GetExecutingAssembly());
// Assert.That(repo.GetMethods().ToList().Count == 8);
// }
//
// [Test]
// public void ContextSupplyTest()
// {
// var repo = new ContextRepository();
// repo.FillSingletons(Assembly.GetExecutingAssembly());
// var singleObject = repo.GetSingleObject(typeof(ITestController)) as ITestController;
// singleObject.B();
// Assert.That(singleObject.B() == 6);
// }
//
// [Test]
// public void TransmissionTest()
// {
// _interactionModule.PassCommand(132, """
// {
// "CommandId": 4
// }
// """u8.ToArray());
// var response =
// JsonSerializer.Deserialize<TransmittedSharedObject<IContextRepository>>(
// JsonSerializer.Deserialize<FinalCommandExecution>(_interactionModule.OutputBuffer.Last())
// ?.Result.ToString()
// );
//
// _interactionModule.PassCommand(132, Encoding.UTF8.GetBytes(
// JsonSerializer.Serialize(new DefaultCallRequest { CommandId = 2, ObjectId = response.ContextId })));
//
// var firstFull = JsonDocument.Parse(_interactionModule.OutputBuffer.Last()).RootElement.GetProperty("Result")
// .GetInt32();
//
// _interactionModule.PassCommand(132, Encoding.UTF8.GetBytes(
// JsonSerializer.Serialize(new DefaultCallRequest { CommandId = 4, ObjectId = response.ContextId })));
//
// response =
// JsonSerializer.Deserialize<TransmittedSharedObject<IContextRepository>>(
// JsonSerializer.Deserialize<FinalCommandExecution>(_interactionModule.OutputBuffer.Last())
// ?.Result.ToString()
// );
//
// _interactionModule.PassCommand(132, Encoding.UTF8.GetBytes(
// JsonSerializer.Serialize(new DefaultCallRequest { CommandId = 2, ObjectId = response.ContextId })));
// _interactionModule.PassCommand(132, Encoding.UTF8.GetBytes(
// JsonSerializer.Serialize(new DefaultCallRequest { CommandId = 2, ObjectId = response.ContextId })));
//
// var secondFull = JsonDocument.Parse(_interactionModule.OutputBuffer.Last()).RootElement.GetProperty("Result")
// .GetInt32();
//
// Assert.That(firstFull == 456789 && secondFull == 6);
// }
//
// [Test]
// public void LinkedObjectsAndParametersTest()
// {
// _interactionModule.PassCommand(132, """
// {
// "CommandId": 6
// }
// """u8.ToArray());
// var response =
// JsonSerializer.Deserialize<TransmittedSharedObject<ITestParameter>>(
// JsonSerializer.Deserialize<FinalCommandExecution>(_interactionModule.OutputBuffer.Last())
// ?.Result.ToString()
// );
// var x = response.ContextId;
// _interactionModule.PassCommand(132,Encoding.UTF8.GetBytes(
// JsonSerializer.Serialize(new DefaultCallRequest
// {
// CommandId = 5,
// Parameter = new TestParameter
// {
// A = 10,
// LinkedObject = new TransmittedSharedObject<ITestParameter> { ContextId = x }
// }
// })));
//
// var finalResponse = JsonDocument.Parse(_interactionModule.OutputBuffer.Last()).RootElement.GetProperty("Result").GetInt32();
//
// Assert.That(finalResponse, Is.EqualTo(20));
// }
// }
+1 -1
View File
@@ -5,6 +5,6 @@ namespace mROA.Abstract
public interface IExecuteModule : IInjectableModule public interface IExecuteModule : IInjectableModule
{ {
ICommandExecution Execute(ICallRequest command, IContextRepository contextRepository, ICommandExecution Execute(ICallRequest command, IContextRepository contextRepository,
IRepresentationModule representationModule); IRepresentationModule representationModule, IEndPointContext context);
} }
} }
@@ -28,7 +28,7 @@ namespace mROA.Implementation.Backend
} }
public ICommandExecution Execute(ICallRequest command, IContextRepository contextRepository, public ICommandExecution Execute(ICallRequest command, IContextRepository contextRepository,
IRepresentationModule representationModule) IRepresentationModule representationModule, IEndPointContext endPointContext)
{ {
#if TRACE #if TRACE
Console.WriteLine(command.GetType().Name); Console.WriteLine(command.GetType().Name);
@@ -58,7 +58,7 @@ namespace mROA.Implementation.Backend
object?[]? castedParams = null; object?[]? castedParams = null;
if (invoker.ParameterTypes.Length != 0) if (invoker.ParameterTypes.Length != 0)
castedParams = CastedParams(command, invoker); castedParams = CastedParams(command, invoker, endPointContext);
var execContext = new RequestContext(command.Id, representationModule.Id); var execContext = new RequestContext(command.Id, representationModule.Id);
@@ -68,10 +68,10 @@ namespace mROA.Implementation.Backend
case AsyncMethodInvoker { IsVoid: false } asyncNonVoidMethodInvoker: case AsyncMethodInvoker { IsVoid: false } asyncNonVoidMethodInvoker:
return TypedExecuteAsync(asyncNonVoidMethodInvoker, context, castedParams, command, return TypedExecuteAsync(asyncNonVoidMethodInvoker, context, castedParams, command,
_cancellationRepo!, _cancellationRepo!,
representationModule, execContext); representationModule, execContext, endPointContext);
case AsyncMethodInvoker asyncMethodInvoker: case AsyncMethodInvoker asyncMethodInvoker:
return ExecuteAsync(asyncMethodInvoker, context, castedParams, command, _cancellationRepo!, return ExecuteAsync(asyncMethodInvoker, context, castedParams, command, _cancellationRepo!,
representationModule, execContext); representationModule, execContext, endPointContext);
default: default:
var result = Execute((invoker as MethodInvoker)!, context, castedParams!, command, execContext); var result = Execute((invoker as MethodInvoker)!, context, castedParams!, command, execContext);
if (command.CommandId == -1) if (command.CommandId == -1)
@@ -104,12 +104,12 @@ namespace mROA.Implementation.Backend
return context; return context;
} }
private object?[] CastedParams(ICallRequest command, IMethodInvoker invoker) private object?[] CastedParams(ICallRequest command, IMethodInvoker invoker, IEndPointContext context)
{ {
object?[] castedParams = new object[invoker.ParameterTypes.Length]; object?[] castedParams = new object[invoker.ParameterTypes.Length];
for (var i = 0; i < castedParams.Length; i++) for (var i = 0; i < castedParams.Length; i++)
{ {
castedParams[i] = _serialization!.Cast(command.Parameters![i], invoker.ParameterTypes[i]); castedParams[i] = _serialization!.Cast(command.Parameters![i], invoker.ParameterTypes[i], context);
} }
return castedParams; return castedParams;
@@ -184,7 +184,7 @@ namespace mROA.Implementation.Backend
private ICommandExecution ExecuteAsync(AsyncMethodInvoker invoker, object instance, object?[]? parameters, private ICommandExecution ExecuteAsync(AsyncMethodInvoker invoker, object instance, object?[]? parameters,
ICallRequest command, ICancellationRepository cancellationRepository, ICallRequest command, ICancellationRepository cancellationRepository,
IRepresentationModule representationModule, RequestContext executionContext) IRepresentationModule representationModule, RequestContext executionContext, IEndPointContext context)
{ {
var tokenSource = new CancellationTokenSource(); var tokenSource = new CancellationTokenSource();
cancellationRepository.RegisterCancellation(command.Id, tokenSource); cancellationRepository.RegisterCancellation(command.Id, tokenSource);
@@ -211,7 +211,7 @@ namespace mROA.Implementation.Backend
multiClientOwnershipRepository?.RegisterOwnership(representationModule.Id); multiClientOwnershipRepository?.RegisterOwnership(representationModule.Id);
if (invoker.IsTrusted) if (invoker.IsTrusted)
representationModule.PostCallMessage(command.Id, EMessageType.FinishedCommandExecution, representationModule.PostCallMessage(command.Id, EMessageType.FinishedCommandExecution,
payload); payload, context);
multiClientOwnershipRepository?.FreeOwnership(); multiClientOwnershipRepository?.FreeOwnership();
}); });
@@ -237,7 +237,7 @@ namespace mROA.Implementation.Backend
private ICommandExecution TypedExecuteAsync(AsyncMethodInvoker invoker, object instance, object?[]? parameters, private ICommandExecution TypedExecuteAsync(AsyncMethodInvoker invoker, object instance, object?[]? parameters,
ICallRequest command, ICancellationRepository cancellationRepository, ICallRequest command, ICancellationRepository cancellationRepository,
IRepresentationModule representationModule, RequestContext executionContext) IRepresentationModule representationModule, RequestContext executionContext, IEndPointContext context)
{ {
var tokenSource = new CancellationTokenSource(); var tokenSource = new CancellationTokenSource();
cancellationRepository.RegisterCancellation(command.Id, tokenSource); cancellationRepository.RegisterCancellation(command.Id, tokenSource);
@@ -259,7 +259,7 @@ namespace mROA.Implementation.Backend
TransmissionConfig.OwnershipRepository as MultiClientOwnershipRepository; TransmissionConfig.OwnershipRepository as MultiClientOwnershipRepository;
multiClientOwnershipRepository?.RegisterOwnership(representationModule.Id); multiClientOwnershipRepository?.RegisterOwnership(representationModule.Id);
representationModule.PostCallMessage(command.Id, EMessageType.FinishedCommandExecution, representationModule.PostCallMessage(command.Id, EMessageType.FinishedCommandExecution,
payload); payload, context);
multiClientOwnershipRepository?.FreeOwnership(); multiClientOwnershipRepository?.FreeOwnership();
}); });
+6 -3
View File
@@ -17,7 +17,7 @@ namespace mROA.Implementation.Backend
private Dictionary<IPEndPoint, int> _reservedPorts = new(); private Dictionary<IPEndPoint, int> _reservedPorts = new();
private CancellationTokenSource _tokenSource = new(); private CancellationTokenSource _tokenSource = new();
private IContextualSerializationToolKit _serializationToolkit; private IContextualSerializationToolKit _serializationToolkit;
private IEndPointContext _context;
public UdpGateway(IPEndPoint listeningEndpoint) public UdpGateway(IPEndPoint listeningEndpoint)
{ {
_client = new UdpClient(listeningEndpoint); _client = new UdpClient(listeningEndpoint);
@@ -34,6 +34,9 @@ namespace mROA.Implementation.Backend
case IContextualSerializationToolKit serializationToolkit: case IContextualSerializationToolKit serializationToolkit:
_serializationToolkit = serializationToolkit; _serializationToolkit = serializationToolkit;
break; break;
case IEndPointContext context:
_context = context;
break;
} }
} }
@@ -51,7 +54,7 @@ namespace mROA.Implementation.Backend
while (token.IsCancellationRequested == false) while (token.IsCancellationRequested == false)
{ {
var incoming = await _client.ReceiveAsync(); var incoming = await _client.ReceiveAsync();
var parsed = _serializationToolkit.Deserialize<NetworkMessageHeader>(incoming.Buffer); var parsed = _serializationToolkit.Deserialize<NetworkMessageHeader>(incoming.Buffer, _context);
try try
{ {
int channelId; int channelId;
@@ -87,7 +90,7 @@ namespace mROA.Implementation.Backend
or EventRequest)) or EventRequest))
continue; continue;
var parsed = _serializationToolkit.Serialize(post); var parsed = _serializationToolkit.Serialize(post, _context);
await _client.SendAsync(parsed, parsed.Length, endpoint); await _client.SendAsync(parsed, parsed.Length, endpoint);
} }
} }
@@ -1,5 +1,7 @@
using System; using System;
#if TRACE
using System.Diagnostics; using System.Diagnostics;
#endif
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using mROA.Abstract; using mROA.Abstract;
@@ -18,6 +20,7 @@ namespace mROA.Implementation.Frontend
private IRepresentationModule? _representationModule; private IRepresentationModule? _representationModule;
private IContextualSerializationToolKit? _serializationToolkit; private IContextualSerializationToolKit? _serializationToolkit;
private IEndPointContext _context; private IEndPointContext _context;
public void Inject<T>(T dependency) public void Inject<T>(T dependency)
{ {
switch (dependency) switch (dependency)
@@ -70,7 +73,8 @@ namespace mROA.Implementation.Frontend
var query = _representationModule!.GetStream(m => var query = _representationModule!.GetStream(m =>
m.MessageType is EMessageType.CallRequest or EMessageType.CancelRequest m.MessageType is EMessageType.CallRequest or EMessageType.CancelRequest
or EMessageType.EventRequest or EMessageType.ClientDisconnect, _context, streamTokenSource.Token, or EMessageType.EventRequest or EMessageType.ClientDisconnect, _context,
streamTokenSource.Token,
m => m.MessageType == EMessageType.CallRequest ? typeof(DefaultCallRequest) : null, m => m.MessageType == EMessageType.CallRequest ? typeof(DefaultCallRequest) : null,
m => m.MessageType == EMessageType.CancelRequest ? typeof(CancelRequest) : null, m => m.MessageType == EMessageType.CancelRequest ? typeof(CancelRequest) : null,
m => m.MessageType == EMessageType.EventRequest ? typeof(DefaultCallRequest) : null, m => m.MessageType == EMessageType.EventRequest ? typeof(DefaultCallRequest) : null,
@@ -11,7 +11,7 @@ namespace mROA.Implementation.Frontend
{ {
private IContextualSerializationToolKit _serializationToolkit; private IContextualSerializationToolKit _serializationToolkit;
private IChannelInteractionModule _channelInteractionModule; private IChannelInteractionModule _channelInteractionModule;
private CancellationTokenSource _tokenSource = new CancellationTokenSource(); private CancellationTokenSource _tokenSource = new();
public void Dispose() public void Dispose()
{ {