diff --git a/mROA.Test/UnitTest1.cs b/mROA.Test/UnitTest1.cs index 3d8bac4..4736608 100644 --- a/mROA.Test/UnitTest1.cs +++ b/mROA.Test/UnitTest1.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using System.Reflection; +using System.Text; using System.Text.Json; using mROA.Implementation; using Newtonsoft.Json; @@ -43,7 +44,7 @@ public class Tests "RequestTypeId": 0, "CommandId": 2 } - """); + """u8.ToArray()); Assert.Pass(_interactionModule.OutputBuffer.Last()); } @@ -56,7 +57,7 @@ public class Tests "RequestTypeId": 0, "CommandId": 3 } - """); + """u8.ToArray()); while (_interactionModule.OutputBuffer.Count != 2) ; Assert.Pass(_interactionModule.OutputBuffer.Last()); @@ -87,21 +88,21 @@ public class Tests { "CommandId": 4 } - """); + """u8.ToArray()); var response = JsonSerializer.Deserialize>( JsonSerializer.Deserialize(_interactionModule.OutputBuffer.Last()) ?.Result.ToString() ); - _interactionModule.PassCommand(132, - JsonSerializer.Serialize(new JsonCallRequest { CommandId = 2, ObjectId = response.ContextId })); + _interactionModule.PassCommand(132, Encoding.UTF8.GetBytes( + JsonSerializer.Serialize(new JsonCallRequest { CommandId = 2, ObjectId = response.ContextId }))); var firstFull = JsonDocument.Parse(_interactionModule.OutputBuffer.Last()).RootElement.GetProperty("Result") .GetInt32(); - _interactionModule.PassCommand(132, - JsonSerializer.Serialize(new JsonCallRequest { CommandId = 4, ObjectId = response.ContextId })); + _interactionModule.PassCommand(132, Encoding.UTF8.GetBytes( + JsonSerializer.Serialize(new JsonCallRequest { CommandId = 4, ObjectId = response.ContextId }))); response = JsonSerializer.Deserialize>( @@ -109,10 +110,10 @@ public class Tests ?.Result.ToString() ); - _interactionModule.PassCommand(132, - JsonSerializer.Serialize(new JsonCallRequest { CommandId = 2, ObjectId = response.ContextId })); - _interactionModule.PassCommand(132, - JsonSerializer.Serialize(new JsonCallRequest { CommandId = 2, ObjectId = response.ContextId })); + _interactionModule.PassCommand(132, Encoding.UTF8.GetBytes( + JsonSerializer.Serialize(new JsonCallRequest { CommandId = 2, ObjectId = response.ContextId }))); + _interactionModule.PassCommand(132, Encoding.UTF8.GetBytes( + JsonSerializer.Serialize(new JsonCallRequest { CommandId = 2, ObjectId = response.ContextId }))); var secondFull = JsonDocument.Parse(_interactionModule.OutputBuffer.Last()).RootElement.GetProperty("Result") .GetInt32(); @@ -127,14 +128,14 @@ public class Tests { "CommandId": 6 } - """); + """u8.ToArray()); var response = JsonSerializer.Deserialize>( JsonSerializer.Deserialize(_interactionModule.OutputBuffer.Last()) ?.Result.ToString() ); var x = response.ContextId; - _interactionModule.PassCommand(132, + _interactionModule.PassCommand(132,Encoding.UTF8.GetBytes( JsonSerializer.Serialize(new JsonCallRequest { CommandId = 5, @@ -143,7 +144,7 @@ public class Tests A = 10, LinkedObject = new TransmittedSharedObject { ContextId = x } } - })); + }))); var finalResponse = JsonDocument.Parse(_interactionModule.OutputBuffer.Last()).RootElement.GetProperty("Result").GetInt32(); diff --git a/mROA/Abstract/IInteractionModule.cs b/mROA/Abstract/IInteractionModule.cs index 5658e6d..ef4d0d6 100644 --- a/mROA/Abstract/IInteractionModule.cs +++ b/mROA/Abstract/IInteractionModule.cs @@ -2,6 +2,11 @@ namespace mROA; public interface IInteractionModule { - void SetMessageHandler(Action handler); + void SetMessageHandler(Action handler); void SendTo(int clientId, byte[] message); + public interface IFrontendInteractionModule + { + public byte[] ReceiveMessage(); + public void PostMessage(byte[] message); + } } \ No newline at end of file diff --git a/mROA/Abstract/ISerialisationModule.cs b/mROA/Abstract/ISerialisationModule.cs index a7d0934..b246944 100644 --- a/mROA/Abstract/ISerialisationModule.cs +++ b/mROA/Abstract/ISerialisationModule.cs @@ -4,13 +4,12 @@ namespace mROA; public interface ISerialisationModule { - void HandleIncomingRequest(int clientId, string command); + void HandleIncomingRequest(int clientId, byte[] command); void PostResponse(ICommandExecution call); void SetExecuteModule(IExecuteModule executeModule); public interface IFrontendSerialisationModule { - void HandlePostedResponse(string response); + ICommandExecution GetNextCommandExecution(Guid requestId); void PostCallRequest(ICallRequest callRequest); - Task GetCommandExecutionResult(Guid callRequestId, CancellationToken cancellationToken); } } \ No newline at end of file diff --git a/mROA/Implementation/JsonFrontendSerialisationModule.cs b/mROA/Implementation/JsonFrontendSerialisationModule.cs index a8f7a10..8e56948 100644 --- a/mROA/Implementation/JsonFrontendSerialisationModule.cs +++ b/mROA/Implementation/JsonFrontendSerialisationModule.cs @@ -4,19 +4,13 @@ namespace mROA.Implementation; public class JsonFrontendSerialisationModule : ISerialisationModule.IFrontendSerialisationModule { - public void HandlePostedResponse(string response) + public ICommandExecution GetNextCommandExecution(Guid requestId) { - + return null; } - - + public void PostCallRequest(ICallRequest callRequest) { } - - public async Task GetCommandExecutionResult(Guid callRequestId, CancellationToken cancellationToken) - { - throw new NotImplementedException(); - } } \ No newline at end of file diff --git a/mROA/Implementation/JsonSerialisationModule.cs b/mROA/Implementation/JsonSerialisationModule.cs index 20c9907..eacaba1 100644 --- a/mROA/Implementation/JsonSerialisationModule.cs +++ b/mROA/Implementation/JsonSerialisationModule.cs @@ -18,7 +18,7 @@ public class JsonSerialisationModule : ISerialisationModule public void SetExecuteModule(IExecuteModule executeModule) => _executeModule = executeModule; - public void HandleIncomingRequest(int clientId, string command) + public void HandleIncomingRequest(int clientId, byte[] command) { JsonCallRequest request = JsonSerializer.Deserialize(command); request.ClientId = clientId; diff --git a/mROA/Implementation/Test/MockSerializationModule.cs b/mROA/Implementation/Test/MockSerializationModule.cs index f5544fe..3f4635c 100644 --- a/mROA/Implementation/Test/MockSerializationModule.cs +++ b/mROA/Implementation/Test/MockSerializationModule.cs @@ -2,7 +2,7 @@ public class MockSerializationModule : ISerialisationModule { - public void HandleIncomingRequest(int clientId, string command) + public void HandleIncomingRequest(int clientId, byte[] command) { } diff --git a/mROA/Implementation/Test/ProgramlyInteractionChanel.cs b/mROA/Implementation/Test/ProgramlyInteractionChanel.cs index b2116e4..d08a814 100644 --- a/mROA/Implementation/Test/ProgramlyInteractionChanel.cs +++ b/mROA/Implementation/Test/ProgramlyInteractionChanel.cs @@ -2,12 +2,12 @@ public class ProgramlyInteractionChanel : IInteractionModule { - public void PassCommand(int clientId, string message) => _handler(clientId, message); - private Action _handler; + public void PassCommand(int clientId, byte[] message) => _handler(clientId, message); + private Action _handler; public List OutputBuffer = new List(); - public void SetMessageHandler(Action handler) + public void SetMessageHandler(Action handler) { _handler = handler; }