добавлена асинхронность

This commit is contained in:
2025-02-03 10:42:47 +03:00
parent 1f2df53c12
commit b2f16b27f4
9 changed files with 49 additions and 32 deletions
+35 -19
View File
@@ -95,9 +95,8 @@ public class TransmissionTestController : ITestController
public TransmittedSharedObject<ITestController> SharedObjectTransmitionTest()
{
TransmittedSharedObject<ITestController> x = new TestController();
return new TestController { ReturnIfNotNull = this };
}
@@ -118,47 +117,64 @@ public class TestParameter
public TransmittedSharedObject<ITestParameter> LinkedObject { get; set; }
}
public class TestControllerRemoteEndoint : ITestController, IRemoteObject
public class TestControllerRemoteEndoint(int id, ISerialisationModule.IFrontendSerialisationModule serialisationModule)
: ITestController, IRemoteObject
{
public TestControllerRemoteEndoint(int id)
{
_id = id;
}
public void A()
{
serialisationModule.PostCallRequest(new JsonCallRequest { CommandId = 0, ObjectId = id });
}
public Task AAsync(CancellationToken cancellationToken)
public async Task AAsync(CancellationToken cancellationToken)
{
var request = new JsonCallRequest { CommandId = 1, ObjectId = id };
serialisationModule.PostCallRequest(request);
await serialisationModule.GetNextCommandExecution<FinalCommandExecution>(request.CallRequestId);
}
public int B()
{
var request = new JsonCallRequest { CommandId = 2, ObjectId = id };
serialisationModule.PostCallRequest(request);
var response = serialisationModule.GetNextCommandExecution<FinalCommandExecution>(request.CallRequestId)
.GetAwaiter().GetResult();
return (int)response.Result!;
}
public Task<int> BAsync(CancellationToken cancellationToken)
public async Task<int> BAsync(CancellationToken cancellationToken)
{
var request = new JsonCallRequest { CommandId = 3, ObjectId = id };
serialisationModule.PostCallRequest(request);
var response = await serialisationModule.GetNextCommandExecution<FinalCommandExecution>(request.CallRequestId);
return (int)response.Result!;
}
public TransmittedSharedObject<ITestController> SharedObjectTransmitionTest()
{
var request = new JsonCallRequest { CommandId = 4, ObjectId = id };
serialisationModule.PostCallRequest(request);
var response = serialisationModule.GetNextCommandExecution<FinalCommandExecution>(request.CallRequestId)
.GetAwaiter().GetResult();
return (TransmittedSharedObject<ITestController>)response.Result!;
}
public int Parametrized(TestParameter parameter)
{
var request = new JsonCallRequest { CommandId = 5, ObjectId = id, Parameter = parameter };
serialisationModule.PostCallRequest(request);
var response = serialisationModule.GetNextCommandExecution<FinalCommandExecution>(request.CallRequestId)
.GetAwaiter().GetResult();
return (int)response.Result!;
}
public TransmittedSharedObject<ITestParameter> GetTestParameter()
{
var request = new JsonCallRequest { CommandId = 6, ObjectId = id };
serialisationModule.PostCallRequest(request);
var response = serialisationModule.GetNextCommandExecution<FinalCommandExecution>(request.CallRequestId)
.GetAwaiter().GetResult();
return (TransmittedSharedObject<ITestParameter>)response.Result!;
}
private int _id;
public int Id => _id;
public int Id => id;
}
+1 -1
View File
@@ -52,7 +52,7 @@ public class StreamTest
var req = new JsonCallRequest { CommandId = 1, ObjectId = -1 };
_frontendSerialisationModule.PostCallRequest(req);
var res = ((JsonElement)_frontendSerialisationModule.GetNextCommandExecution<FinalCommandExecution>(req.CallRequestId).Result).Deserialize<MockResult>();
var res = ((JsonElement)_frontendSerialisationModule.GetNextCommandExecution<FinalCommandExecution>(req.CallRequestId).GetAwaiter().GetResult().Result!).Deserialize<MockResult>();
isTestNotFinished = false;
Assert.That(res.A == "wqer" && res.B == 5);
}