diff --git a/Example.Backend/Example.Backend.csproj b/Example.Backend/Example.Backend.csproj
index 3eac518..4f357b7 100644
--- a/Example.Backend/Example.Backend.csproj
+++ b/Example.Backend/Example.Backend.csproj
@@ -10,6 +10,10 @@
9
+
+
+
+
diff --git a/Example.Backend/Printer.cs b/Example.Backend/Printer.cs
index 92960e4..a5ba4ac 100644
--- a/Example.Backend/Printer.cs
+++ b/Example.Backend/Printer.cs
@@ -1,6 +1,4 @@
using System;
-using System.Security.Cryptography;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Example.Shared;
diff --git a/Example.Frontend/Program.cs b/Example.Frontend/Program.cs
index 08ec27a..98d4f5f 100644
--- a/Example.Frontend/Program.cs
+++ b/Example.Frontend/Program.cs
@@ -1,5 +1,4 @@
using System;
-using System.Diagnostics;
using System.Net;
using System.Text;
using System.Threading;
diff --git a/mROA.Benchmark/Program.cs b/mROA.Benchmark/Program.cs
index a99f392..217a6d7 100644
--- a/mROA.Benchmark/Program.cs
+++ b/mROA.Benchmark/Program.cs
@@ -1,8 +1,6 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
using BenchmarkDotNet.Attributes;
-using BenchmarkDotNet.Running;
namespace mROA.Benchmark
{
diff --git a/mROA.Cbor/CborSerializationToolkit.cs b/mROA.Cbor/CborSerializationToolkit.cs
index f950fff..af66e5e 100644
--- a/mROA.Cbor/CborSerializationToolkit.cs
+++ b/mROA.Cbor/CborSerializationToolkit.cs
@@ -4,7 +4,6 @@ using System.Collections.Generic;
using System.Formats.Cbor;
using System.Linq;
using System.Reflection;
-using System.Text.Json;
using mROA.Abstract;
using mROA.Implementation;
using mROA.Implementation.Attributes;
diff --git a/mROA.sln b/mROA.sln
index 34c47ba..6899901 100644
--- a/mROA.sln
+++ b/mROA.sln
@@ -27,18 +27,18 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Debug|Any CPU.ActiveCfg = Release|Any CPU
- {AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Debug|Any CPU.Build.0 = Release|Any CPU
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Release|Any CPU.Build.0 = Release|Any CPU
+ {AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {AE4E93F6-7B91-41FC-9BEA-2C8C2CBE1CB6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D0E5760B-BB6E-453A-B396-A972CD94F133}.Release|Any CPU.Build.0 = Release|Any CPU
- {6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.ActiveCfg = Release|Any CPU
- {6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.Build.0 = Release|Any CPU
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Release|Any CPU.Build.0 = Release|Any CPU
+ {6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {6CE0ED21-88FD-44B3-B9C6-9B8FA4E07E89}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9BB364E-0BA6-40B9-A293-757BC48EFC06}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A9BB364E-0BA6-40B9-A293-757BC48EFC06}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A9BB364E-0BA6-40B9-A293-757BC48EFC06}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/mROA/Abstract/ISerialisationModule.cs b/mROA/Abstract/ISerialisationModule.cs
index a25e00e..a297fd8 100644
--- a/mROA/Abstract/ISerialisationModule.cs
+++ b/mROA/Abstract/ISerialisationModule.cs
@@ -1,7 +1,6 @@
using System;
using System.Threading;
using System.Threading.Tasks;
-using System.Windows.Input;
using mROA.Implementation;
using mROA.Implementation.CommandExecution;
diff --git a/mROA/Implementation/Backend/BasicExecutionModule.cs b/mROA/Implementation/Backend/BasicExecutionModule.cs
index 56ec2ea..3173d37 100644
--- a/mROA/Implementation/Backend/BasicExecutionModule.cs
+++ b/mROA/Implementation/Backend/BasicExecutionModule.cs
@@ -21,8 +21,9 @@ namespace mROA.Implementation.Backend
public ICommandExecution Execute(ICallRequest command, IContextRepository contextRepository,
IRepresentationModule representationModule)
{
+#if TRACE
Console.WriteLine(command.GetType().Name);
-
+#endif
if (_cancellationRepo is null)
throw new NullReferenceException("Method repository was not defined");
@@ -34,7 +35,9 @@ namespace mROA.Implementation.Backend
if (command is CancelRequest)
{
+#if TRACE
Console.WriteLine("Final cancelling request");
+#endif
var cts = _cancellationRepo.GetCancellation(command.Id);
cts.Cancel();
_cancellationRepo.FreeCancelation(command.Id);
@@ -68,7 +71,9 @@ namespace mROA.Implementation.Backend
var result = Execute(currentCommand, context, parameter, command);
if (command.CommandId == -1)
{
+#if TRACE
Console.WriteLine("Disposing object");
+#endif
contextRepository.ClearObject(command.ObjectId);
}
@@ -118,7 +123,9 @@ namespace mROA.Implementation.Backend
var tokenSource = new CancellationTokenSource();
cancellationRepository.RegisterCancellation(command.Id, tokenSource);
var token = tokenSource.Token;
+#if TRACE
token.Register(() => Console.WriteLine($"Cancellation requested check {command.Id}"));
+#endif
try
{
var finalParameter = parameter is null
diff --git a/mROA/Implementation/Frontend/RequestExtractor.cs b/mROA/Implementation/Frontend/RequestExtractor.cs
index 87741e8..cfcf9ce 100644
--- a/mROA/Implementation/Frontend/RequestExtractor.cs
+++ b/mROA/Implementation/Frontend/RequestExtractor.cs
@@ -63,7 +63,9 @@ namespace mROA.Implementation.Frontend
{
while (true)
{
+#if TRACE
Console.WriteLine("Waiting for request...");
+#endif
var tokenSource = new CancellationTokenSource();
var token = tokenSource.Token;
var defaultRequest =
@@ -74,12 +76,15 @@ namespace mROA.Implementation.Frontend
messageType: MessageType.CancelRequest, token: token);
Task.WaitAny(defaultRequest, cancelRequest);
-
+
+#if TRACE
Console.WriteLine("Request received");
-
+#endif
if (cancelRequest.IsCompleted)
{
+#if TRACE
Console.WriteLine("Cancelling request");
+#endif
var req = cancelRequest.Result;
tokenSource.Cancel();
_executeModule.Execute(req, _contextRepository, _representationModule);
diff --git a/mROA/Implementation/NextGenerationInteractionModule.cs b/mROA/Implementation/NextGenerationInteractionModule.cs
index f31664c..e9416e9 100644
--- a/mROA/Implementation/NextGenerationInteractionModule.cs
+++ b/mROA/Implementation/NextGenerationInteractionModule.cs
@@ -87,7 +87,9 @@ namespace mROA.Implementation
// Console.WriteLine("Receiving {0}", Encoding.Default.GetString(_buffer[..len]));
var message = _serialization.Deserialize(localSpan.Span);
+#if TRACE
Console.WriteLine($"Received Message {message.SchemaId} - {message.Id}");
+#endif
_messageBuffer.Add(message);
_currentReceiving = Task.Run(async () => await GetNextMessage());
diff --git a/mROA/Implementation/RemoteObjectBase.cs b/mROA/Implementation/RemoteObjectBase.cs
index 0c993f1..a81c255 100644
--- a/mROA/Implementation/RemoteObjectBase.cs
+++ b/mROA/Implementation/RemoteObjectBase.cs
@@ -42,7 +42,9 @@ namespace mROA.Implementation
cancellationToken.Register(async () =>
{
+#if TRACE
Console.WriteLine("Cancelling task");
+#endif
await _representationModule.PostCallMessageAsync(request.Id, MessageType.CancelRequest,
new CancelRequest
{
@@ -92,7 +94,9 @@ namespace mROA.Implementation
cancellationToken.Register(async () =>
{
+#if TRACE
Console.WriteLine("Cancelling task");
+#endif
await _representationModule.PostCallMessageAsync(request.Id, MessageType.CancelRequest,
new CancelRequest
{
@@ -106,8 +110,9 @@ namespace mROA.Implementation
errorResponse, successResponse
}, cancellationToken);
+#if TRACE
Console.WriteLine($"Handling message");
-
+#endif
if (successResponse.IsCompletedSuccessfully)
return;
diff --git a/mROA/Implementation/RepresentationModule.cs b/mROA/Implementation/RepresentationModule.cs
index 67c26ce..73e2275 100644
--- a/mROA/Implementation/RepresentationModule.cs
+++ b/mROA/Implementation/RepresentationModule.cs
@@ -23,9 +23,11 @@ namespace mROA.Implementation
}
}
- public int Id => (_interaction ?? throw new NullReferenceException("Interaction is not initialized")).ConnectionId;
+ public int Id => (_interaction ?? throw new NullReferenceException("Interaction is not initialized"))
+ .ConnectionId;
- public async Task GetMessageAsync(Guid? requestId, MessageType? messageType, CancellationToken token = default)
+ public async Task GetMessageAsync(Guid? requestId, MessageType? messageType,
+ CancellationToken token = default)
{
if (_serialization == null)
throw new NullReferenceException("Serialization toolkit is not initialized");
@@ -43,25 +45,26 @@ namespace mROA.Implementation
return _serialization.Deserialize(rawMessage)!;
}
- public async Task GetRawMessage(Guid? requestId = null, MessageType? messageType = null, CancellationToken token = default)
+ public async Task GetRawMessage(Guid? requestId = null, MessageType? messageType = null,
+ CancellationToken token = default)
{
if (_interaction == null)
throw new NullReferenceException("Interaction toolkit is not initialized");
-
+
var fromBuffer =
_interaction.FirstByFilter(message =>
(requestId is null || message.Id == requestId) &&
(messageType is null || message.SchemaId == messageType));
-
+
if (fromBuffer == null)
{
while (token.IsCancellationRequested == false)
{
var message = await _interaction.GetNextMessageReceiving();
if ((requestId is not null && message.Id != requestId) ||
- (messageType is not null && message.SchemaId != messageType))
+ (messageType is not null && message.SchemaId != messageType))
continue;
-
+
_interaction.HandleMessage(message);
return message.Data;
}
@@ -82,8 +85,9 @@ namespace mROA.Implementation
throw new NullReferenceException("Interaction toolkit is not initialized");
if (_serialization == null)
throw new NullReferenceException("Serialization toolkit is not initialized");
-
+#if TRACE
Console.WriteLine($"Posting message: {id} - {messageType}");
+#endif
var serialized = _serialization.Serialize(payload, payloadType);
await _interaction.PostMessage(new NetworkMessage
diff --git a/mROA/Implementation/SharedObject.cs b/mROA/Implementation/SharedObject.cs
index f99d420..e2e112c 100644
--- a/mROA/Implementation/SharedObject.cs
+++ b/mROA/Implementation/SharedObject.cs
@@ -79,7 +79,8 @@ namespace mROA.Implementation
}
}
- [JsonIgnore] public T Value { get; private set; }
+ [JsonIgnore]
+ public T Value { get; private set; }
// ReSharper disable once MemberCanBePrivate.Global
// ReSharper disable once UnusedMember.Global
@@ -106,6 +107,7 @@ namespace mROA.Implementation
public static implicit operator SharedObject(T value) =>
new(value);
+ [JsonIgnore]
public IEndPointContext EndPointContext { get; set; } = new EndPointContext
{
RealRepository = TransmissionConfig.RealContextRepository,
diff --git a/mROA/LegacyExtentions.cs b/mROA/LegacyExtentions.cs
index d35c5a9..d0a3b29 100644
--- a/mROA/LegacyExtentions.cs
+++ b/mROA/LegacyExtentions.cs
@@ -1,8 +1,7 @@
-using System.Collections.Generic;
-using global::System;
-using global::System.IO;
-using global::System.Threading;
-using global::System.Threading.Tasks;
+using System;
+using System.IO;
+using System.Threading;
+using System.Threading.Tasks;
namespace mROA
{
diff --git a/mROA/mROA.csproj b/mROA/mROA.csproj
index a436d48..cb237bf 100644
--- a/mROA/mROA.csproj
+++ b/mROA/mROA.csproj
@@ -12,6 +12,16 @@
git
RPC
9
+ Debug;Release
+ AnyCPU
+
+
+
+
+
+
+
+