Event binding bug found

This commit is contained in:
2025-05-07 09:03:20 +03:00
parent 99015a3d5e
commit 2f65fb24c0
5 changed files with 13 additions and 12 deletions
+4 -5
View File
@@ -16,11 +16,11 @@ using mROA.Implementation.Frontend;
class Program class Program
{ {
public static void Main(string[] args) public static async Task Main(string[] args)
{ {
var builder = new FullMixBuilder(); var builder = new FullMixBuilder();
new RemoteTypeBinder(); new RemoteTypeBinder();
// builder.Modules.Add(new JsonSerializationToolkit());
builder.Modules.Add(new CborSerializationToolkit()); builder.Modules.Add(new CborSerializationToolkit());
builder.Modules.Add(new EndPointContext()); builder.Modules.Add(new EndPointContext());
builder.Modules.Add(new RemoteContextRepository()); builder.Modules.Add(new RemoteContextRepository());
@@ -39,7 +39,7 @@ class Program
builder.Build(); builder.Build();
var frontendBridge = builder.GetModule<IFrontendBridge>()!; var frontendBridge = builder.GetModule<IFrontendBridge>()!;
frontendBridge.Connect(); await frontendBridge.Connect();
_ = builder.GetModule<RequestExtractor>()!.StartExtraction(); _ = builder.GetModule<RequestExtractor>()!.StartExtraction();
_ = builder.GetModule<UdpUntrustedInteraction>().Start(serverEndPoint); _ = builder.GetModule<UdpUntrustedInteraction>().Start(serverEndPoint);
Console.WriteLine(builder.GetModule<IEndPointContext>().HostId); Console.WriteLine(builder.GetModule<IEndPointContext>().HostId);
@@ -87,8 +87,7 @@ class Program
Console.WriteLine("Names: " + string.Join(", ", names)); Console.WriteLine("Names: " + string.Join(", ", names));
var page = disposingPrinter.Print("Test Page", false, default, CancellationToken.None).GetAwaiter() var page = await disposingPrinter.Print("Test Page", false, default, CancellationToken.None);
.GetResult();
Console.WriteLine("Page printed"); Console.WriteLine("Page printed");
DemoCheck.TaskExecution = true; DemoCheck.TaskExecution = true;
Console.WriteLine(page.ToString()); Console.WriteLine(page.ToString());
+2 -1
View File
@@ -213,7 +213,8 @@ namespace mROA.Cbor
if (obj is IShared) if (obj is IShared)
{ {
var generic = obj.GetType().GetInterfaces().FirstOrDefault(i => typeof(IShared).IsAssignableFrom(i)); var interfaces = obj.GetType().GetInterfaces();
var generic = interfaces.FirstOrDefault(i => typeof(IShared).IsAssignableFrom(i));
var sharedShell = typeof(SharedObjectShellShell<>).MakeGenericType(generic); var sharedShell = typeof(SharedObjectShellShell<>).MakeGenericType(generic);
var so = var so =
Activator.CreateInstance(sharedShell, obj, context) as Activator.CreateInstance(sharedShell, obj, context) as
+2 -1
View File
@@ -1,10 +1,11 @@
using System; using System;
using System.Threading.Tasks;
namespace mROA.Abstract namespace mROA.Abstract
{ {
public interface IFrontendBridge : IInjectableModule, IDisposable public interface IFrontendBridge : IInjectableModule, IDisposable
{ {
void Connect(); Task Connect();
void Obstacle(); void Obstacle();
void Disconnect(); void Disconnect();
} }
@@ -33,8 +33,8 @@ namespace mROA.Implementation.Backend
{ {
var last = _storage.Place(o); var last = _storage.Place(o);
EventBinders.OfType<IEventBinder<T>>().FirstOrDefault() var binder = EventBinders.OfType<IEventBinder<T>>().FirstOrDefault();
?.BindEvents((T)o, context, _representationModuleProducer!, last); binder?.BindEvents((T)o, context, _representationModuleProducer!, last);
return last; return last;
} }
@@ -40,7 +40,7 @@ namespace mROA.Implementation.Frontend
} }
} }
public void Connect() public async Task Connect()
{ {
if (_interactionModule is null) if (_interactionModule is null)
throw new Exception("Interaction module was not injected"); throw new Exception("Interaction module was not injected");
@@ -57,7 +57,7 @@ namespace mROA.Implementation.Frontend
.Wait(); .Wait();
_currentExtractor.SingleReceive(); _currentExtractor.SingleReceive();
var idMessage = _interactionModule.GetNextMessageReceiving(false).GetAwaiter().GetResult(); var idMessage = await _interactionModule.GetNextMessageReceiving(false);
if (idMessage.MessageType != EMessageType.IdAssigning) if (idMessage.MessageType != EMessageType.IdAssigning)
{ {