Fix udp constructor
This commit is contained in:
@@ -19,9 +19,9 @@ class Program
|
|||||||
{
|
{
|
||||||
public static async Task Main(string[] args)
|
public static async Task Main(string[] args)
|
||||||
{
|
{
|
||||||
var builder = new FullMixBuilder();
|
|
||||||
new RemoteTypeBinder();
|
new RemoteTypeBinder();
|
||||||
|
|
||||||
|
|
||||||
builder.Modules.Add(new CborSerializationToolkit());
|
builder.Modules.Add(new CborSerializationToolkit());
|
||||||
builder.Modules.Add(new EndPointContext());
|
builder.Modules.Add(new EndPointContext());
|
||||||
builder.Modules.Add(new RemoteInstanceRepository());
|
builder.Modules.Add(new RemoteInstanceRepository());
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.Net;
|
|||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
using mROA.Abstract;
|
using mROA.Abstract;
|
||||||
using static mROA.Implementation.EMessageType;
|
using static mROA.Implementation.EMessageType;
|
||||||
|
|
||||||
@@ -16,14 +17,12 @@ namespace mROA.Implementation.Backend
|
|||||||
private Dictionary<IPEndPoint, int> _reservedPorts = new();
|
private Dictionary<IPEndPoint, int> _reservedPorts = new();
|
||||||
private CancellationTokenSource _tokenSource = new();
|
private CancellationTokenSource _tokenSource = new();
|
||||||
private IContextualSerializationToolKit _serializationToolkit;
|
private IContextualSerializationToolKit _serializationToolkit;
|
||||||
private IEndPointContext _context;
|
|
||||||
|
|
||||||
public UdpGateway(IPEndPoint listeningEndpoint, IConnectionHub hub, IContextualSerializationToolKit serializationToolkit, IEndPointContext context)
|
public UdpGateway(IOptions<GatewayOptions> options, IConnectionHub hub, IContextualSerializationToolKit serializationToolkit)
|
||||||
{
|
{
|
||||||
_hub = hub;
|
_hub = hub;
|
||||||
_serializationToolkit = serializationToolkit;
|
_serializationToolkit = serializationToolkit;
|
||||||
_context = context;
|
_client = new UdpClient(options.Value.Endpoint);
|
||||||
_client = new UdpClient(listeningEndpoint);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -41,7 +40,7 @@ namespace mROA.Implementation.Backend
|
|||||||
while (token.IsCancellationRequested == false)
|
while (token.IsCancellationRequested == false)
|
||||||
{
|
{
|
||||||
var incoming = await _client.ReceiveAsync();
|
var incoming = await _client.ReceiveAsync();
|
||||||
var parsed = _serializationToolkit.Deserialize<NetworkMessageHeader>(incoming.Buffer, _context);
|
var parsed = _serializationToolkit.Deserialize<NetworkMessageHeader>(incoming.Buffer, null);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int channelId;
|
int channelId;
|
||||||
@@ -77,7 +76,7 @@ namespace mROA.Implementation.Backend
|
|||||||
or EventRequest))
|
or EventRequest))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var parsed = _serializationToolkit.Serialize(post, _context);
|
var parsed = _serializationToolkit.Serialize(post, null);
|
||||||
await _client.SendAsync(parsed, parsed.Length, endpoint);
|
await _client.SendAsync(parsed, parsed.Length, endpoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user