diff --git a/Example.Backend/PagesList.cs b/Example.Backend/PagesList.cs index 1b195c9..35db8f1 100644 --- a/Example.Backend/PagesList.cs +++ b/Example.Backend/PagesList.cs @@ -8,7 +8,7 @@ namespace Example.Backend { public class PagesList : RemoteObjectBase, IPagesList { - public PagesList(int id, IRepresentationModule representationModule) : base(id, representationModule) + public PagesList(int id, IRepresentationModule representationModule,IEndPointContext context) : base(id, representationModule, context) { } diff --git a/Example.Backend/Program.cs b/Example.Backend/Program.cs index 408f880..95f8c36 100644 --- a/Example.Backend/Program.cs +++ b/Example.Backend/Program.cs @@ -44,10 +44,7 @@ class Program builder.Build(); new RemoteTypeBinder(); - - TransmissionConfig.RealContextRepository = builder.GetModule()!; - TransmissionConfig.RemoteEndpointContextRepository = builder.GetModule()!; - TransmissionConfig.OwnershipRepository = new MultiClientOwnershipRepository(); + _ = builder.GetModule()!.Start(); var gateway = builder.GetModule(); diff --git a/Example.Frontend/Program.cs b/Example.Frontend/Program.cs index e9cbf51..9abe3b1 100644 --- a/Example.Frontend/Program.cs +++ b/Example.Frontend/Program.cs @@ -37,21 +37,17 @@ class Program builder.Modules.Add(new CancellationRepository()); builder.Build(); - - - TransmissionConfig.RealContextRepository = builder.GetModule(); - TransmissionConfig.RemoteEndpointContextRepository = builder.GetModule(); - + var frontendBridge = builder.GetModule()!; frontendBridge.Connect(); _ = builder.GetModule()!.StartExtraction(); _ = builder.GetModule().Start(serverEndPoint); - Console.WriteLine(TransmissionConfig.OwnershipRepository.GetOwnershipId()); + Console.WriteLine(builder.GetModule().HostId); var context = builder.GetModule(); var factory = context.GetSingleObject(typeof(IPrinterFactory), - -TransmissionConfig.OwnershipRepository.GetHostOwnershipId()) as IPrinterFactory; + builder.GetModule()) as IPrinterFactory; using (var disposingPrinter = factory.Create("Test")) { @@ -89,7 +85,7 @@ class Program var names = factory.CollectAllNames(); Thread.Sleep(100); - Console.WriteLine(string.Join(", ", names)); + Console.WriteLine("Names: " + string.Join(", ", names)); var page = disposingPrinter.Print("Test Page", false, default, CancellationToken.None).GetAwaiter() .GetResult(); @@ -114,7 +110,7 @@ class Program DemoCheck.Dispose = true; - var loadSingleton = context.GetSingleObject(typeof(ILoadTest), 0) as ILoadTest; + var loadSingleton = context.GetSingleObject(typeof(ILoadTest), builder.GetModule()) as ILoadTest; var cts = new CancellationTokenSource(); diff --git a/mROA.Cbor/CborSerializationToolkit.cs b/mROA.Cbor/CborSerializationToolkit.cs index 47d1fc0..425cbe3 100644 --- a/mROA.Cbor/CborSerializationToolkit.cs +++ b/mROA.Cbor/CborSerializationToolkit.cs @@ -216,10 +216,8 @@ namespace mROA.Cbor var generic = obj.GetType().GetInterfaces().FirstOrDefault(i => typeof(IShared).IsAssignableFrom(i)); var sharedShell = typeof(SharedObjectShellShell<>).MakeGenericType(generic); var so = - Activator.CreateInstance(sharedShell, obj) as + Activator.CreateInstance(sharedShell, obj, context) as ISharedObjectShell; - if (context != null) - so.EndPointContext = context; writer.WriteStartArray(1); writer.WriteUInt64(so.Identifier.Flat); diff --git a/mROA.Codegen/RemoteEndpoint.cstmpl b/mROA.Codegen/RemoteEndpoint.cstmpl index 8a2541a..0ee69af 100644 --- a/mROA.Codegen/RemoteEndpoint.cstmpl +++ b/mROA.Codegen/RemoteEndpoint.cstmpl @@ -10,8 +10,8 @@ namespace partial class : RemoteObjectBase, { - public (int id, IRepresentationModule representationModule) - : base(id, representationModule) + public (int id, IRepresentationModule representationModule, IEndPointContext context) + : base(id, representationModule, context) { } diff --git a/mROA.Codegen/RemoteTypeBinder.cstmpl b/mROA.Codegen/RemoteTypeBinder.cstmpl index be2bf42..bbef815 100644 --- a/mROA.Codegen/RemoteTypeBinder.cstmpl +++ b/mROA.Codegen/RemoteTypeBinder.cstmpl @@ -39,7 +39,7 @@ namespace mROA.Codegen Parameters = new object[] { } }; - module.PostCallMessageAsync(request.Id, EMessageType.EventRequest, request); + module.PostCallMessageAsync(request.Id, EMessageType.EventRequest, request, context); }; } diff --git a/mROA.Test/Identifier.cs b/mROA.Test/Identifier.cs new file mode 100644 index 0000000..6b929bc --- /dev/null +++ b/mROA.Test/Identifier.cs @@ -0,0 +1,23 @@ +using mROA.Implementation; + +namespace mROA.Test; + +[TestFixture] +public class Identifier +{ + [Test] + public void TestParse() + { + var id = new ComplexObjectIdentifier(-1, -1); + var flat = id.Flat; + var next = new ComplexObjectIdentifier { Flat = flat }; + if (id.Equals(next)) + { + Assert.Pass(); + } + else + { + Assert.Fail(); + } + } +} \ No newline at end of file diff --git a/mROA.sln b/mROA.sln index 2c090e8..40a367e 100644 --- a/mROA.sln +++ b/mROA.sln @@ -23,8 +23,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mROA.Cbor", "mROA.Cbor\mROA EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TotalDemo", "TotalDemo", "{FC4FA752-10A7-4D78-A7C2-9BCD8A81FB5E}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Codegen", "Codegen", "{3DB22457-E65B-426F-B3DD-08C615132B3E}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -72,6 +70,5 @@ Global {A9BB364E-0BA6-40B9-A293-757BC48EFC06} = {FC4FA752-10A7-4D78-A7C2-9BCD8A81FB5E} {9BD25A13-3165-47C0-9EAA-5C59EC490E32} = {FC4FA752-10A7-4D78-A7C2-9BCD8A81FB5E} {E7703F5B-F2A6-4A88-AA57-EBB1E38D533E} = {FC4FA752-10A7-4D78-A7C2-9BCD8A81FB5E} - {3DB22457-E65B-426F-B3DD-08C615132B3E} = {EAE92F5A-664C-41AB-8811-5885524B5347} EndGlobalSection EndGlobal diff --git a/mROA/Abstract/IContextRepository.cs b/mROA/Abstract/IContextRepository.cs index c4d6c3e..f4857c7 100644 --- a/mROA/Abstract/IContextRepository.cs +++ b/mROA/Abstract/IContextRepository.cs @@ -7,9 +7,9 @@ namespace mROA.Abstract { int HostId { get; set; } int ResisterObject(object o, IEndPointContext context); - void ClearObject(ComplexObjectIdentifier id); + void ClearObject(ComplexObjectIdentifier id, IEndPointContext context); T GetObject(ComplexObjectIdentifier id, IEndPointContext context); - object GetSingleObject(Type type, int ownerId); + object GetSingleObject(Type type, IEndPointContext context); int GetObjectIndex(object o, IEndPointContext context); } } \ No newline at end of file diff --git a/mROA/Abstract/IRemoteObjectFactory.cs b/mROA/Abstract/IRemoteObjectFactory.cs index e68fb0f..1ae127f 100644 --- a/mROA/Abstract/IRemoteObjectFactory.cs +++ b/mROA/Abstract/IRemoteObjectFactory.cs @@ -4,6 +4,6 @@ namespace mROA.Abstract { public interface IRemoteObjectFactory : IInjectableModule { - T Produce(ComplexObjectIdentifier id); + T Produce(ComplexObjectIdentifier id, IEndPointContext context); } } \ No newline at end of file diff --git a/mROA/Implementation/Backend/BackendIdentityGenerator.cs b/mROA/Implementation/Backend/BackendIdentityGenerator.cs index dce88be..bf9fcdb 100644 --- a/mROA/Implementation/Backend/BackendIdentityGenerator.cs +++ b/mROA/Implementation/Backend/BackendIdentityGenerator.cs @@ -8,7 +8,7 @@ namespace mROA.Implementation.Backend public int GetNextIdentity() { - return ++_currentId; + return -++_currentId; } public void Inject(T dependency) diff --git a/mROA/Implementation/Backend/BasicConfigurationExtensions.cs b/mROA/Implementation/Backend/BasicConfigurationExtensions.cs index b8e0f7c..57b5f65 100644 --- a/mROA/Implementation/Backend/BasicConfigurationExtensions.cs +++ b/mROA/Implementation/Backend/BasicConfigurationExtensions.cs @@ -23,7 +23,6 @@ namespace mROA.Implementation.Backend { var repo = new ContextRepository(); repo.FillSingletons(assemblies); - TransmissionConfig.RealContextRepository = repo; builder.Modules.Add(repo); } diff --git a/mROA/Implementation/Backend/BasicExecutionModule.cs b/mROA/Implementation/Backend/BasicExecutionModule.cs index f161e20..d5f3f09 100644 --- a/mROA/Implementation/Backend/BasicExecutionModule.cs +++ b/mROA/Implementation/Backend/BasicExecutionModule.cs @@ -79,7 +79,7 @@ namespace mROA.Implementation.Backend #if TRACE Console.WriteLine("Disposing object"); #endif - contextRepository.ClearObject(command.ObjectId); + contextRepository.ClearObject(command.ObjectId, endPointContext); } return result; @@ -100,7 +100,7 @@ namespace mROA.Implementation.Backend { var context = command.ObjectId.ContextId != -1 ? contextRepository.GetObject(command.ObjectId, endPointContext) - : contextRepository.GetSingleObject(invoker.SuitableType, command.ObjectId.OwnerId); + : contextRepository.GetSingleObject(invoker.SuitableType, endPointContext); return context; } @@ -205,14 +205,10 @@ namespace mROA.Implementation.Backend }; _cancellationRepo?.FreeCancelation(command.Id); - var multiClientOwnershipRepository = - TransmissionConfig.OwnershipRepository as MultiClientOwnershipRepository; - - multiClientOwnershipRepository?.RegisterOwnership(representationModule.Id); + if (invoker.IsTrusted) representationModule.PostCallMessage(command.Id, EMessageType.FinishedCommandExecution, payload, context); - multiClientOwnershipRepository?.FreeOwnership(); }); return new AsyncCommandExecution @@ -254,13 +250,9 @@ namespace mROA.Implementation.Backend Result = finalResult }; _cancellationRepo!.FreeCancelation(command.Id); - - var multiClientOwnershipRepository = - TransmissionConfig.OwnershipRepository as MultiClientOwnershipRepository; - multiClientOwnershipRepository?.RegisterOwnership(representationModule.Id); + representationModule.PostCallMessage(command.Id, EMessageType.FinishedCommandExecution, payload, context); - multiClientOwnershipRepository?.FreeOwnership(); }); return new AsyncCommandExecution diff --git a/mROA/Implementation/Backend/ConnectionHub.cs b/mROA/Implementation/Backend/ConnectionHub.cs index 34c7064..ddaf694 100644 --- a/mROA/Implementation/Backend/ConnectionHub.cs +++ b/mROA/Implementation/Backend/ConnectionHub.cs @@ -23,7 +23,7 @@ namespace mROA.Implementation.Backend public IChannelInteractionModule GetInteraction(int id) { - return _connections!.GetValueOrDefault(id, null) ?? throw new Exception("No connection found"); + return _connections!.GetValueOrDefault(id, null) ?? _connections!.GetValueOrDefault(-id, null) ?? throw new Exception("No connection found"); } public event ConnectionHandler? OnConnected; diff --git a/mROA/Implementation/Backend/ContextRepository.cs b/mROA/Implementation/Backend/ContextRepository.cs index 5448101..13541c5 100644 --- a/mROA/Implementation/Backend/ContextRepository.cs +++ b/mROA/Implementation/Backend/ContextRepository.cs @@ -39,7 +39,7 @@ namespace mROA.Implementation.Backend return last; } - public void ClearObject(ComplexObjectIdentifier id) + public void ClearObject(ComplexObjectIdentifier id, IEndPointContext context) { _storage.Free(id.ContextId); } @@ -56,7 +56,7 @@ namespace mROA.Implementation.Backend return (T)value; } - public object GetSingleObject(Type type, int ownerId) + public object GetSingleObject(Type type, IEndPointContext context) { return _singletons.GetValueOrDefault(type.GetHashCode()) ?? throw new ArgumentException("Unregistered singleton type"); diff --git a/mROA/Implementation/Backend/HubRequestExtractor.cs b/mROA/Implementation/Backend/HubRequestExtractor.cs index 9c0a2d3..7c35b33 100644 --- a/mROA/Implementation/Backend/HubRequestExtractor.cs +++ b/mROA/Implementation/Backend/HubRequestExtractor.cs @@ -57,16 +57,17 @@ namespace mROA.Implementation.Backend var extractor = new RequestExtractor(); var context = new EndPointContext { - HostId = 0, OwnerId = interaction.Id + HostId = 0, OwnerId = -interaction.Id }; extractor.Inject(interaction); - if (_contextRepository is IContextRepositoryHub contextHub) context.RealRepository = contextHub.GetRepository(interaction.Id); else context.RealRepository = _contextRepository!; context.RemoteRepository = _remoteContextRepository!; + + extractor.Inject(context); extractor.Inject(_methodRepository); extractor.Inject(_serializationToolkit); extractor.Inject(_executeModule); diff --git a/mROA/Implementation/Backend/MultiClientContextRepository.cs b/mROA/Implementation/Backend/MultiClientContextRepository.cs index 370f105..8d63cd3 100644 --- a/mROA/Implementation/Backend/MultiClientContextRepository.cs +++ b/mROA/Implementation/Backend/MultiClientContextRepository.cs @@ -22,31 +22,31 @@ namespace mROA.Implementation.Backend public int ResisterObject(object o, IEndPointContext context) { - var repository = GetRepositoryByClientId(TransmissionConfig.OwnershipRepository.GetOwnershipId()); + var repository = GetRepositoryByClientId(context.OwnerId); return repository.ResisterObject(o, context); } - public void ClearObject(ComplexObjectIdentifier id) + public void ClearObject(ComplexObjectIdentifier id, IEndPointContext context) { - var repository = GetRepositoryByClientId(TransmissionConfig.OwnershipRepository.GetOwnershipId()); - repository.ClearObject(id); + var repository = GetRepositoryByClientId(context.OwnerId); + repository.ClearObject(id, context); } public T GetObject(ComplexObjectIdentifier id, IEndPointContext context) { - var repository = GetRepositoryByClientId(TransmissionConfig.OwnershipRepository.GetOwnershipId()); + var repository = GetRepositoryByClientId(context.OwnerId); return repository.GetObject(id, context); } - public object GetSingleObject(Type type, int ownerId) + public object GetSingleObject(Type type, IEndPointContext context) { - var repository = GetRepositoryByClientId(TransmissionConfig.OwnershipRepository.GetOwnershipId()); - return repository.GetSingleObject(type, ownerId); + var repository = GetRepositoryByClientId(context.OwnerId); + return repository.GetSingleObject(type, context); } public int GetObjectIndex(object o, IEndPointContext context) { - var repository = GetRepositoryByClientId(TransmissionConfig.OwnershipRepository.GetOwnershipId()); + var repository = GetRepositoryByClientId(context.OwnerId); return repository.GetObjectIndex(o, context); } diff --git a/mROA/Implementation/Backend/NetworkGatewayModule.cs b/mROA/Implementation/Backend/NetworkGatewayModule.cs index 7f19f32..8fe538c 100644 --- a/mROA/Implementation/Backend/NetworkGatewayModule.cs +++ b/mROA/Implementation/Backend/NetworkGatewayModule.cs @@ -94,11 +94,11 @@ namespace mROA.Implementation.Backend { case EMessageType.ClientConnect: context.HostId = 0; - context.OwnerId = interaction.ConnectionId; + context.OwnerId = -interaction.ConnectionId; Task.Run(async () => await streamExtractor.LoopedReceive(cts.Token)); _ = streamExtractor.SendFromChannel(interaction.TrustedPostChanel, cts.Token); interaction.PostMessageAsync(new NetworkMessageHeader(_serialization!, - new IdAssignment { Id = -interaction.ConnectionId }, null)); + new IdAssignment { Id = interaction.ConnectionId }, null)); _extractorsCTS[interaction.ConnectionId] = cts; _hub!.RegisterInteraction(interaction); Console.WriteLine("Client registered"); @@ -108,7 +108,7 @@ namespace mROA.Implementation.Backend var recoveryRequest = _serialization!.Deserialize(connectionRequest.Data, null); var recoveryInteraction = _hub.GetInteraction(recoveryRequest.Id); - _extractorsCTS[recoveryRequest.Id].Cancel(); + _extractorsCTS[-recoveryRequest.Id].Cancel(); recoveryInteraction.IsConnected = () => streamExtractor.IsConnected; streamExtractor.MessageReceived = message => diff --git a/mROA/Implementation/ComplexContextRepository.cs b/mROA/Implementation/ComplexContextRepository.cs index bcd8285..b074da9 100644 --- a/mROA/Implementation/ComplexContextRepository.cs +++ b/mROA/Implementation/ComplexContextRepository.cs @@ -47,7 +47,7 @@ namespace mROA.Implementation return placedIndex; } - public void ClearObject(ComplexObjectIdentifier id) + public void ClearObject(ComplexObjectIdentifier id, IEndPointContext context) { _storages.Find(i => i.Key == id.OwnerId).Value.Free(id.ContextId); } @@ -57,7 +57,7 @@ namespace mROA.Implementation throw new NotImplementedException(); } - public object GetSingleObject(Type type, int ownerId) + public object GetSingleObject(Type type, IEndPointContext context) { throw new NotImplementedException(); } diff --git a/mROA/Implementation/ComplexObjectIdentifier.cs b/mROA/Implementation/ComplexObjectIdentifier.cs index d95d378..ae2e4e0 100644 --- a/mROA/Implementation/ComplexObjectIdentifier.cs +++ b/mROA/Implementation/ComplexObjectIdentifier.cs @@ -32,7 +32,7 @@ namespace mROA.Implementation public ulong Flat { - get => (ulong)OwnerId << 32 | (uint)ContextId; + get => (ulong)((long)OwnerId << 32 | (uint)ContextId); set { OwnerId = (int)(value >> 32); diff --git a/mROA/Implementation/Frontend/NetworkFrontendBridge.cs b/mROA/Implementation/Frontend/NetworkFrontendBridge.cs index 049a108..2b287fa 100644 --- a/mROA/Implementation/Frontend/NetworkFrontendBridge.cs +++ b/mROA/Implementation/Frontend/NetworkFrontendBridge.cs @@ -73,7 +73,6 @@ namespace mROA.Implementation.Frontend var assignment = _serialization.Deserialize(idMessage.Data, _context); _interactionModule.ConnectionId = -assignment.Id; - TransmissionConfig.OwnershipRepository = new StaticOwnershipRepository(assignment.Id); _context.HostId = assignment.Id; _context.OwnerId = assignment.Id; } diff --git a/mROA/Implementation/Frontend/UdpUntrustedInteraction.cs b/mROA/Implementation/Frontend/UdpUntrustedInteraction.cs index e2e7421..941ac08 100644 --- a/mROA/Implementation/Frontend/UdpUntrustedInteraction.cs +++ b/mROA/Implementation/Frontend/UdpUntrustedInteraction.cs @@ -46,7 +46,7 @@ namespace mROA.Implementation.Frontend var initMessage = new NetworkMessageHeader { MessageType = EMessageType.UntrustedConnect, Id = Guid.NewGuid(), - Data = BitConverter.GetBytes(Math.Abs(_channelInteractionModule.ConnectionId)) + Data = BitConverter.GetBytes(_channelInteractionModule.ConnectionId) }; var initParsed = _serializationToolkit.Serialize(initMessage, _context); diff --git a/mROA/Implementation/RemoteContextRepository.cs b/mROA/Implementation/RemoteContextRepository.cs index a6af325..9ab5dd8 100644 --- a/mROA/Implementation/RemoteContextRepository.cs +++ b/mROA/Implementation/RemoteContextRepository.cs @@ -18,7 +18,7 @@ namespace mROA.Implementation throw new NotSupportedException(); } - public void ClearObject(ComplexObjectIdentifier id) + public void ClearObject(ComplexObjectIdentifier id, IEndPointContext context) { throw new NotSupportedException(); } @@ -33,7 +33,7 @@ namespace mROA.Implementation if (!RemoteTypes.TryGetValue(typeof(T), out var remoteType)) throw new NotSupportedException(); var representationModule = - _representationProducer.Produce(TransmissionConfig.OwnershipRepository.GetOwnershipId()); + _representationProducer.Produce(context.OwnerId); var remote = (T)Activator.CreateInstance(remoteType, id.ContextId, representationModule, context)!; @@ -42,16 +42,16 @@ namespace mROA.Implementation return remote; } - public object GetSingleObject(Type type, int ownerId) + public object GetSingleObject(Type type, IEndPointContext context) { if (_representationProducer == null) throw new NullReferenceException("representation producer is not initialized"); var representationModule = - _representationProducer.Produce(ownerId); + _representationProducer.Produce(context.OwnerId); _producedRemoteEndpoints.Add((Activator.CreateInstance(RemoteTypes[type], -1, - representationModule) as RemoteObjectBase)!); + representationModule, context) as RemoteObjectBase)!); return _producedRemoteEndpoints.Last(); } diff --git a/mROA/Implementation/RemoteObjectFactory.cs b/mROA/Implementation/RemoteObjectFactory.cs index fad21e3..8fa0873 100644 --- a/mROA/Implementation/RemoteObjectFactory.cs +++ b/mROA/Implementation/RemoteObjectFactory.cs @@ -9,14 +9,14 @@ namespace mROA.Implementation public static Dictionary RemoteTypes = new(); private IRepresentationModuleProducer? _representationProducer; - public T Produce(ComplexObjectIdentifier id) + public T Produce(ComplexObjectIdentifier id, IEndPointContext context) { if (_representationProducer == null) throw new NullReferenceException("representation producer is not initialized"); if (!RemoteTypes.TryGetValue(typeof(T), out var remoteType)) throw new NotSupportedException(); var representationModule = - _representationProducer.Produce(TransmissionConfig.OwnershipRepository.GetOwnershipId()); + _representationProducer.Produce(context.OwnerId); var remote = (T)Activator.CreateInstance(remoteType, id.ContextId, representationModule)!; return remote; diff --git a/mROA/Implementation/RepresentationModule.cs b/mROA/Implementation/RepresentationModule.cs index 14db0fd..bb9d40c 100644 --- a/mROA/Implementation/RepresentationModule.cs +++ b/mROA/Implementation/RepresentationModule.cs @@ -55,7 +55,8 @@ namespace mROA.Implementation } public async IAsyncEnumerable<(object parced, EMessageType originalType)> GetStream( - Predicate rule, IEndPointContext? context, [EnumeratorCancellation] CancellationToken token = default, + Predicate rule, IEndPointContext? context, + [EnumeratorCancellation] CancellationToken token = default, params Func[] converter) { var writer = _interaction?.ReceiveChanel.Writer; @@ -72,15 +73,14 @@ namespace mROA.Implementation yield return (deserialized, message.MessageType)!; } } - - public async Task PostCallMessageAsync(Guid id, EMessageType eMessageType, T payload, - IEndPointContext? context) where T : notnull - { - await PostCallMessageAsync(id, eMessageType, payload, context); - } - public async Task PostCallMessageAsync(Guid id, EMessageType eMessageType, object payload, - IEndPointContext? context) + // public async Task PostCallMessageAsync(Guid id, EMessageType eMessageType, T payload, + // IEndPointContext? context) where T : notnull + // { + // await this.PostCallMessageAsync(id, eMessageType, payload, context); + // } + + public async Task PostCallMessageAsync(Guid id, EMessageType eMessageType, T payload, IEndPointContext? context) where T : notnull { if (_interaction == null) throw new NullReferenceException("Interaction toolkit is not initialized"); @@ -92,7 +92,8 @@ namespace mROA.Implementation { Id = id, MessageType = eMessageType, Data = serialized }); } - public void PostCallMessage(Guid id, EMessageType eMessageType, T payload, IEndPointContext? context) where T : notnull + public void PostCallMessage(Guid id, EMessageType eMessageType, T payload, IEndPointContext? context) + where T : notnull { PostCallMessageAsync(id, eMessageType, payload, context).GetAwaiter().GetResult(); } diff --git a/mROA/Implementation/SharedObjectShell.cs b/mROA/Implementation/SharedObjectShell.cs index d595a23..01305db 100644 --- a/mROA/Implementation/SharedObjectShell.cs +++ b/mROA/Implementation/SharedObjectShell.cs @@ -4,7 +4,7 @@ using mROA.Abstract; using mROA.Implementation.Attributes; // ReSharper disable UnusedMember.Global -#pragma warning disable CS8618, CS9264 +// #pragma warning disable CS8618, CS9264 namespace mROA.Implementation { @@ -30,8 +30,9 @@ namespace mROA.Implementation // ReSharper disable once UnusedMember.Global // ReSharper disable once MemberCanBePrivate.Global - public SharedObjectShellShell(T value) + public SharedObjectShellShell(T value, IEndPointContext endPointContext) { + EndPointContext = endPointContext; Value = value; } @@ -57,15 +58,7 @@ namespace mROA.Implementation } } - [SerializationIgnore] - [JsonIgnore] - public IEndPointContext EndPointContext { get; set; } = new EndPointContext - { - RealRepository = TransmissionConfig.RealContextRepository, - RemoteRepository = TransmissionConfig.RemoteEndpointContextRepository, - HostId = TransmissionConfig.OwnershipRepository.GetHostOwnershipId(), - OwnerId = 0 - }; + [SerializationIgnore] [JsonIgnore] public IEndPointContext EndPointContext { get; set; } public ComplexObjectIdentifier Identifier { @@ -96,7 +89,7 @@ namespace mROA.Implementation public static implicit operator T(SharedObjectShellShell value) => value.Value; - public static implicit operator SharedObjectShellShell(T value) => - new(value); + // public static implicit operator SharedObjectShellShell(T value) => + // new(value); } } \ No newline at end of file diff --git a/mROA/Implementation/TransmissionConfig.cs b/mROA/Implementation/TransmissionConfig.cs index 5302f9c..013995a 100644 --- a/mROA/Implementation/TransmissionConfig.cs +++ b/mROA/Implementation/TransmissionConfig.cs @@ -9,27 +9,27 @@ namespace mROA.Implementation #if TRACE public static int TotalTransmittedBytes { get; set; } #endif - private static IContextRepository? _realContextRepository; - private static IContextRepository? _remoteEndpointContextRepository; - private static IOwnershipRepository? _ownershipRepository; - - public static IContextRepository RealContextRepository - { - get => _realContextRepository ?? throw new NullReferenceException("RealContextRepository is null"); - set => _realContextRepository = value; - } - - public static IContextRepository RemoteEndpointContextRepository - { - get => _remoteEndpointContextRepository ?? - throw new NullReferenceException("RemoteEndpointContextRepository is null"); - set => _remoteEndpointContextRepository = value; - } - - public static IOwnershipRepository OwnershipRepository - { - get => _ownershipRepository ?? throw new NullReferenceException("OwnershipRepository is null"); - set => _ownershipRepository = value; - } + // private static IContextRepository? _realContextRepository; + // private static IContextRepository? _remoteEndpointContextRepository; + // private static IOwnershipRepository? _ownershipRepository; + // + // public static IContextRepository RealContextRepository + // { + // get => _realContextRepository ?? throw new NullReferenceException("RealContextRepository is null"); + // set => _realContextRepository = value; + // } + // + // public static IContextRepository RemoteEndpointContextRepository + // { + // get => _remoteEndpointContextRepository ?? + // throw new NullReferenceException("RemoteEndpointContextRepository is null"); + // set => _remoteEndpointContextRepository = value; + // } + // + // public static IOwnershipRepository OwnershipRepository + // { + // get => _ownershipRepository ?? throw new NullReferenceException("OwnershipRepository is null"); + // set => _ownershipRepository = value; + // } } } \ No newline at end of file