diff --git a/Example.Frontend/Program.cs b/Example.Frontend/Program.cs index 11501d4..6c518ec 100644 --- a/Example.Frontend/Program.cs +++ b/Example.Frontend/Program.cs @@ -19,9 +19,9 @@ class Program { public static async Task Main(string[] args) { - var builder = new FullMixBuilder(); new RemoteTypeBinder(); + builder.Modules.Add(new CborSerializationToolkit()); builder.Modules.Add(new EndPointContext()); builder.Modules.Add(new RemoteInstanceRepository()); diff --git a/mROA/Implementation/Backend/UdpGateway.cs b/mROA/Implementation/Backend/UdpGateway.cs index ae02db8..c1d30a7 100644 --- a/mROA/Implementation/Backend/UdpGateway.cs +++ b/mROA/Implementation/Backend/UdpGateway.cs @@ -4,6 +4,7 @@ using System.Net; using System.Net.Sockets; using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.Options; using mROA.Abstract; using static mROA.Implementation.EMessageType; @@ -16,14 +17,12 @@ namespace mROA.Implementation.Backend private Dictionary _reservedPorts = new(); private CancellationTokenSource _tokenSource = new(); private IContextualSerializationToolKit _serializationToolkit; - private IEndPointContext _context; - public UdpGateway(IPEndPoint listeningEndpoint, IConnectionHub hub, IContextualSerializationToolKit serializationToolkit, IEndPointContext context) + public UdpGateway(IOptions options, IConnectionHub hub, IContextualSerializationToolKit serializationToolkit) { _hub = hub; _serializationToolkit = serializationToolkit; - _context = context; - _client = new UdpClient(listeningEndpoint); + _client = new UdpClient(options.Value.Endpoint); } @@ -41,7 +40,7 @@ namespace mROA.Implementation.Backend while (token.IsCancellationRequested == false) { var incoming = await _client.ReceiveAsync(); - var parsed = _serializationToolkit.Deserialize(incoming.Buffer, _context); + var parsed = _serializationToolkit.Deserialize(incoming.Buffer, null); try { int channelId; @@ -77,7 +76,7 @@ namespace mROA.Implementation.Backend or EventRequest)) continue; - var parsed = _serializationToolkit.Serialize(post, _context); + var parsed = _serializationToolkit.Serialize(post, null); await _client.SendAsync(parsed, parsed.Length, endpoint); } }