Add C# multi-peer RUDP listener
This commit is contained in:
parent
ba5f4ef824
commit
1c85eabefb
4 changed files with 474 additions and 1 deletions
|
|
@ -290,6 +290,12 @@ Current progress:
|
|||
`ReconnectIfDue(nowMs)` inside their own scheduler, and the shared controller
|
||||
owns retry delay/exhaustion state while the caller-owned factory opens the
|
||||
next `CultNetRudpSocketTransportConnection`.
|
||||
- C# now has `CultNetRudpSocketTransportServer`, a multi-peer UDP listener that
|
||||
demultiplexes remote endpoints into separate RUDP sessions and delivers
|
||||
`(peer, frame)` records to higher service owners. This is the production
|
||||
server substrate cut: UDP/session ownership is no longer limited to the
|
||||
single-peer interop/client helper, but authentication and game-session
|
||||
authority still remain above the transport.
|
||||
- C# `GameCult.Mesh` now mirrors the branded RUDP facade shape used by
|
||||
TypeScript, Python, Kotlin, and Rust: it parses `rudp://host:port` endpoints,
|
||||
creates RUDP client/server transports from endpoint or peer-card contact
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ CultMesh.
|
|||
|
||||
| Runtime | Role | Claimed parity | Not claimed |
|
||||
| --- | --- | --- | --- |
|
||||
| C# | Reference implementation and production game/server substrate | CultCache typed documents and SoA, CultNet schema-v0, LiteNetLib production path with adapter profile, shared transport profiles, shared RUDP socket transport, C# interop RUDP serve/dial path, connected RUDP CultMesh client helpers, RUDP-backed schema-client selection for `rudp://` service endpoints, RUDP reconnect policy/controller and reconnect-loop helper, LiteNetLib client reconnect-controller adoption, schema-client transport port for service request/response clients, CultMesh node/session/catalog/stream/simulation/RUDP surfaces, authorized peer lookup | No need to abandon LiteNetLib before the CultNet adapter fully owns production service adoption |
|
||||
| C# | Reference implementation and production game/server substrate | CultCache typed documents and SoA, CultNet schema-v0, LiteNetLib production path with adapter profile, shared transport profiles, shared RUDP socket transport, C# multi-peer RUDP listener substrate, C# interop RUDP serve/dial path, connected RUDP CultMesh client helpers, RUDP-backed schema-client selection for `rudp://` service endpoints, RUDP reconnect policy/controller and reconnect-loop helper, LiteNetLib client reconnect-controller adoption, schema-client transport port for service request/response clients, CultMesh node/session/catalog/stream/simulation/RUDP surfaces, authorized peer lookup | No need to abandon LiteNetLib before the CultNet adapter fully owns production service adoption |
|
||||
| Python | Package runtime, local daemon endpoint, raw interop peer, typed state participant | CultCache/CultNet/CultMesh package surface, branded CultMesh node/schema/shard/Verse/peer/authority/stream/RUDP ergonomics, authorized peer lookup, shard catalogs/logs, schema-transport factory for raw client request/subscription flows, local TCP and RUDP CultMesh server listeners, Python interop RUDP serve/dial path, session/prediction/simulation fact helpers, RUDP codec/session/socket transport, RUDP reconnect policy/controller and reconnect-loop helper, schema-v0 MessagePack over RUDP evidence, benchmark evidence against C# cache paths | Universal C# throughput, full C# daemon/server stack, and RUDP as the only public service pipe |
|
||||
| TypeScript | Node/browser-adjacent projection and interop runtime | CultCache parity tests, CultNet schema-v0 peer, advertised schema/shard catalog wire contracts plus request/sync helpers, transport profiles, TCP-framed transport port and peer helper, shared RUDP socket transport, RUDP interop serve/dial path, RUDP reconnect policy/controller, RUDP reconnect-loop helper, branded CultMesh node/schema/shard/Verse/peer/authority/stream/RUDP ergonomics, authorized peer lookup | Full C# game session/server stack |
|
||||
| Rust | Low-level cache/transport/runtime substrate | CultCache/CultNet interop lane, schema and shard catalog helpers, transport profiles, TCP-framed port, shared RUDP codec/session/socket transport, Rust interop RUDP serve/dial path, connected RUDP CultMesh client helpers, RUDP reconnect policy/controller and reconnect-loop helper, schema-v0 MessagePack over RUDP evidence, small CultMesh facade for schema registry, shard catalog, peer cards, authority leases, authorized peer lookup, RUDP endpoint parsing, and peer-card/authorized-peer RUDP client construction | Full CultMesh game-session/server facade, stream catalog, or production game-session server |
|
||||
|
|
|
|||
|
|
@ -1941,6 +1941,368 @@ namespace GameCult.Networking
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Options for a multi-peer CultNet RUDP UDP listener.
|
||||
/// </summary>
|
||||
public sealed class CultNetRudpSocketTransportServerOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the runtime id advertised by this listener.
|
||||
/// </summary>
|
||||
public string RuntimeId { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// Gets or sets the bound UDP socket.
|
||||
/// </summary>
|
||||
public Socket Socket { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Gets or sets the RUDP connection/session binding id accepted by this listener.
|
||||
/// </summary>
|
||||
public uint ConnectionId { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the first local packet sequence for each accepted peer session.
|
||||
/// </summary>
|
||||
public uint InitialSequence { get; set; } = 100;
|
||||
/// <summary>
|
||||
/// Gets or sets the resend delay in milliseconds.
|
||||
/// </summary>
|
||||
public long ResendDelayMs { get; set; } = 250;
|
||||
/// <summary>
|
||||
/// Gets or sets the advertised transport id.
|
||||
/// </summary>
|
||||
public string TransportId { get; set; } = "rudp";
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum payload size for RUDP channels.
|
||||
/// </summary>
|
||||
public int? MaxPayloadBytes { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum fragment size for RUDP channels.
|
||||
/// </summary>
|
||||
public int? MaxFragmentBytes { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum pending reliable packet count for RUDP channels.
|
||||
/// </summary>
|
||||
public int? MaxPendingReliablePackets { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the advertised reconnect policy for this RUDP listener.
|
||||
/// </summary>
|
||||
public CultNetReconnectPolicy? ReconnectPolicy { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the payload sent with accept packets.
|
||||
/// </summary>
|
||||
public byte[]? AcceptPayload { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Peer context owned by a multi-peer CultNet RUDP listener.
|
||||
/// </summary>
|
||||
public sealed class CultNetRudpSocketServerPeer
|
||||
{
|
||||
internal CultNetRudpSocketServerPeer(EndPoint remoteEndPoint, CultNetRudpSession session)
|
||||
{
|
||||
RemoteEndPoint = remoteEndPoint;
|
||||
Session = session;
|
||||
}
|
||||
|
||||
internal CultNetRudpSession Session { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the UDP endpoint for this peer.
|
||||
/// </summary>
|
||||
public EndPoint RemoteEndPoint { get; }
|
||||
/// <summary>
|
||||
/// Gets whether the peer RUDP handshake has completed.
|
||||
/// </summary>
|
||||
public bool Connected => Session.Connected;
|
||||
/// <summary>
|
||||
/// Gets the last transport-level remote disconnect reason, if one was received.
|
||||
/// </summary>
|
||||
public byte[]? DisconnectReason { get; internal set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A frame delivered by a multi-peer CultNet RUDP listener.
|
||||
/// </summary>
|
||||
public sealed class CultNetRudpSocketServerFrame
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the peer that delivered the frame.
|
||||
/// </summary>
|
||||
public CultNetRudpSocketServerPeer Peer { get; set; } = null!;
|
||||
/// <summary>
|
||||
/// Gets the delivered transport frame.
|
||||
/// </summary>
|
||||
public CultNetTransportFrame Frame { get; set; } = new CultNetTransportFrame();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Multi-peer UDP socket listener for CultNet RUDP sessions.
|
||||
/// </summary>
|
||||
public sealed class CultNetRudpSocketTransportServer : IDisposable
|
||||
{
|
||||
private readonly Socket _socket;
|
||||
private readonly uint _connectionId;
|
||||
private readonly uint _initialSequence;
|
||||
private readonly long _resendDelayMs;
|
||||
private readonly int? _maxFragmentBytes;
|
||||
private readonly int? _maxPendingReliablePackets;
|
||||
private readonly byte[] _acceptPayload;
|
||||
private readonly CultNetTransportStats _stats = new CultNetTransportStats();
|
||||
private readonly Dictionary<string, CultNetRudpSocketServerPeer> _peers = new Dictionary<string, CultNetRudpSocketServerPeer>(StringComparer.Ordinal);
|
||||
private readonly Queue<CultNetRudpSocketServerFrame> _deliveredFrames = new Queue<CultNetRudpSocketServerFrame>();
|
||||
private bool _disposed;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a multi-peer UDP listener for CultNet RUDP sessions.
|
||||
/// </summary>
|
||||
public CultNetRudpSocketTransportServer(CultNetRudpSocketTransportServerOptions options)
|
||||
{
|
||||
if (options == null) throw new ArgumentNullException(nameof(options));
|
||||
if (string.IsNullOrWhiteSpace(options.RuntimeId)) throw new ArgumentException("Runtime id is required.", nameof(options));
|
||||
_socket = options.Socket ?? throw new ArgumentNullException(nameof(options.Socket));
|
||||
_connectionId = options.ConnectionId;
|
||||
_initialSequence = options.InitialSequence;
|
||||
_resendDelayMs = options.ResendDelayMs;
|
||||
_maxFragmentBytes = options.MaxFragmentBytes;
|
||||
_maxPendingReliablePackets = options.MaxPendingReliablePackets;
|
||||
_acceptPayload = options.AcceptPayload ?? Array.Empty<byte>();
|
||||
|
||||
var local = _socket.LocalEndPoint as IPEndPoint;
|
||||
Profile = CultNetTransportProfiles.CreateRudp(
|
||||
options.RuntimeId,
|
||||
new RudpTransportProfileOptions
|
||||
{
|
||||
TransportId = options.TransportId,
|
||||
Host = local?.Address.ToString(),
|
||||
Port = local?.Port,
|
||||
MaxPayloadBytes = options.MaxPayloadBytes,
|
||||
MaxFragmentBytes = options.MaxFragmentBytes,
|
||||
MaxPendingReliablePackets = options.MaxPendingReliablePackets,
|
||||
ReconnectPolicy = options.ReconnectPolicy
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the profile this listener implements.
|
||||
/// </summary>
|
||||
public CultNetTransportProfile Profile { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets currently tracked peers indexed by remote endpoint.
|
||||
/// </summary>
|
||||
public IReadOnlyCollection<CultNetRudpSocketServerPeer> Peers => _peers.Values.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// Gets a snapshot of the current transfer counters.
|
||||
/// </summary>
|
||||
public CultNetTransportStats Stats => _stats.Snapshot();
|
||||
|
||||
/// <summary>
|
||||
/// Sends a logical transport frame to a connected peer.
|
||||
/// </summary>
|
||||
public void Send(CultNetRudpSocketServerPeer peer, string channelId, byte[] payload)
|
||||
{
|
||||
if (peer == null) throw new ArgumentNullException(nameof(peer));
|
||||
foreach (var packet in peer.Session.SendMany(channelId, payload, ChannelSendOptions(channelId), _maxFragmentBytes))
|
||||
{
|
||||
SendPacket(peer.RemoteEndPoint, packet);
|
||||
}
|
||||
_stats.FramesSent++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a reliable ordered schema-channel payload to a peer.
|
||||
/// </summary>
|
||||
public void SendSchema(CultNetRudpSocketServerPeer peer, byte[] payload)
|
||||
{
|
||||
Send(peer, "schema", payload);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a reliable ordered schema-channel UTF-8 payload to a peer.
|
||||
/// </summary>
|
||||
public void SendSchema(CultNetRudpSocketServerPeer peer, string payload)
|
||||
{
|
||||
SendSchema(peer, Encoding.UTF8.GetBytes(payload ?? string.Empty));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends a CultNet schema-v0 message to a peer on the reliable ordered schema channel.
|
||||
/// </summary>
|
||||
public void SendSchemaMessage<TMessage>(CultNetRudpSocketServerPeer peer, TMessage message)
|
||||
where TMessage : ICultNetSchemaMessage
|
||||
{
|
||||
if (message == null) throw new ArgumentNullException(nameof(message));
|
||||
SendSchema(peer, CultNetSchemaMessageSerialization.Serialize(message));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Polls the UDP socket once and returns the next delivered peer frame if one is available.
|
||||
/// </summary>
|
||||
public CultNetRudpSocketServerFrame? ReceiveOnce()
|
||||
{
|
||||
if (_deliveredFrames.Count > 0)
|
||||
{
|
||||
return _deliveredFrames.Dequeue();
|
||||
}
|
||||
|
||||
var buffer = new byte[65535];
|
||||
EndPoint remote = new IPEndPoint(IPAddress.Any, 0);
|
||||
int received;
|
||||
try
|
||||
{
|
||||
if (!_socket.Poll(0, SelectMode.SelectRead))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
received = _socket.ReceiveFrom(buffer, ref remote);
|
||||
}
|
||||
catch (SocketException error) when (
|
||||
error.SocketErrorCode == SocketError.WouldBlock ||
|
||||
error.SocketErrorCode == SocketError.TimedOut)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
_stats.BytesReceived += received;
|
||||
var wire = new byte[received];
|
||||
Array.Copy(buffer, wire, received);
|
||||
|
||||
CultNetRudpPacket packet;
|
||||
try
|
||||
{
|
||||
packet = CultNetRudpPacketCodec.Decode(wire);
|
||||
}
|
||||
catch (InvalidOperationException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (packet.ConnectionId != _connectionId)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var peerKey = RemoteKey(remote);
|
||||
if (packet.PacketType == CultNetRudpPacketType.Connect)
|
||||
{
|
||||
var peer = new CultNetRudpSocketServerPeer(
|
||||
CloneEndPoint(remote),
|
||||
new CultNetRudpSession(new CultNetRudpSessionOptions
|
||||
{
|
||||
ConnectionId = _connectionId,
|
||||
InitialSequence = _initialSequence,
|
||||
ResendDelayMs = _resendDelayMs,
|
||||
MaxPendingReliablePackets = _maxPendingReliablePackets
|
||||
}));
|
||||
_peers[peerKey] = peer;
|
||||
SendPacket(peer.RemoteEndPoint, peer.Session.AcceptConnect(packet, NowMs(), _acceptPayload));
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!_peers.TryGetValue(peerKey, out var existingPeer))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var result = existingPeer.Session.Receive(packet, NowMs());
|
||||
if (result.Reply != null)
|
||||
{
|
||||
SendPacket(existingPeer.RemoteEndPoint, result.Reply);
|
||||
}
|
||||
if (result.Disconnected)
|
||||
{
|
||||
existingPeer.DisconnectReason = result.DisconnectReason;
|
||||
_peers.Remove(peerKey);
|
||||
return null;
|
||||
}
|
||||
|
||||
foreach (var frame in result.Delivered)
|
||||
{
|
||||
_deliveredFrames.Enqueue(new CultNetRudpSocketServerFrame
|
||||
{
|
||||
Peer = existingPeer,
|
||||
Frame = new CultNetTransportFrame
|
||||
{
|
||||
ChannelId = frame.ChannelId,
|
||||
Payload = frame.Payload
|
||||
}
|
||||
});
|
||||
_stats.FramesReceived++;
|
||||
}
|
||||
|
||||
var delivered = _deliveredFrames.Count > 0 ? _deliveredFrames.Dequeue() : null;
|
||||
if (packet.PacketType == CultNetRudpPacketType.Data || delivered != null)
|
||||
{
|
||||
SendPacket(existingPeer.RemoteEndPoint, existingPeer.Session.CreateAck());
|
||||
}
|
||||
|
||||
return delivered;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sends any reliable packets whose resend timers are due for all peers.
|
||||
/// </summary>
|
||||
public void PollResends()
|
||||
{
|
||||
foreach (var peer in _peers.Values.ToArray())
|
||||
{
|
||||
foreach (var packet in peer.Session.DueResends(NowMs()))
|
||||
{
|
||||
SendPacket(peer.RemoteEndPoint, packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_disposed = true;
|
||||
_socket.Dispose();
|
||||
}
|
||||
|
||||
private void SendPacket(EndPoint remoteEndPoint, CultNetRudpPacket packet)
|
||||
{
|
||||
var wire = CultNetRudpPacketCodec.Encode(packet);
|
||||
var sent = _socket.SendTo(wire, remoteEndPoint);
|
||||
_stats.BytesSent += sent;
|
||||
}
|
||||
|
||||
private static string RemoteKey(EndPoint endpoint)
|
||||
{
|
||||
return endpoint.ToString() ?? string.Empty;
|
||||
}
|
||||
|
||||
private static EndPoint CloneEndPoint(EndPoint endpoint)
|
||||
{
|
||||
if (endpoint is IPEndPoint ip)
|
||||
{
|
||||
return new IPEndPoint(ip.Address, ip.Port);
|
||||
}
|
||||
|
||||
return endpoint;
|
||||
}
|
||||
|
||||
private static CultNetRudpSendOptions ChannelSendOptions(string channelId)
|
||||
{
|
||||
return string.Equals(channelId, "schema", StringComparison.Ordinal)
|
||||
? new CultNetRudpSendOptions { Reliable = true, Ordered = true, NowMs = NowMs() }
|
||||
: string.Equals(channelId, "latest", StringComparison.Ordinal)
|
||||
? new CultNetRudpSendOptions { Sequenced = true, NowMs = NowMs() }
|
||||
: new CultNetRudpSendOptions { NowMs = NowMs() };
|
||||
}
|
||||
|
||||
private static long NowMs()
|
||||
{
|
||||
return DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Caller-owned reconnect loop for the socket-backed CultNet RUDP transport.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1010,6 +1010,111 @@ namespace GameCult.Networking.Tests
|
|||
Assert.That(profile.Transports[0].Protocol, Is.EqualTo("rudp"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RudpSocketTransportServer_DemuxesMultiplePeers()
|
||||
{
|
||||
using var serverSocket = BindUdpSocket();
|
||||
using var firstClientSocket = BindUdpSocket();
|
||||
using var secondClientSocket = BindUdpSocket();
|
||||
var serverEndPoint = serverSocket.LocalEndPoint!;
|
||||
const uint connectionId = 0x10203045;
|
||||
using var server = new CultNetRudpSocketTransportServer(new CultNetRudpSocketTransportServerOptions
|
||||
{
|
||||
RuntimeId = "csharp-rudp-listener",
|
||||
Socket = serverSocket,
|
||||
ConnectionId = connectionId,
|
||||
InitialSequence = 100,
|
||||
ResendDelayMs = 25,
|
||||
MaxFragmentBytes = 1024,
|
||||
AcceptPayload = Encoding.UTF8.GetBytes("accepted")
|
||||
});
|
||||
using var firstClient = new CultNetRudpSocketTransportConnection(new CultNetRudpSocketTransportOptions
|
||||
{
|
||||
RuntimeId = "csharp-rudp-listener-client-a",
|
||||
Socket = firstClientSocket,
|
||||
Mode = CultNetRudpSocketMode.Client,
|
||||
RemoteEndPoint = serverEndPoint,
|
||||
ConnectionId = connectionId,
|
||||
InitialSequence = 1,
|
||||
ResendDelayMs = 25,
|
||||
MaxFragmentBytes = 1024
|
||||
});
|
||||
using var secondClient = new CultNetRudpSocketTransportConnection(new CultNetRudpSocketTransportOptions
|
||||
{
|
||||
RuntimeId = "csharp-rudp-listener-client-b",
|
||||
Socket = secondClientSocket,
|
||||
Mode = CultNetRudpSocketMode.Client,
|
||||
RemoteEndPoint = serverEndPoint,
|
||||
ConnectionId = connectionId,
|
||||
InitialSequence = 10,
|
||||
ResendDelayMs = 25,
|
||||
MaxFragmentBytes = 1024
|
||||
});
|
||||
|
||||
firstClient.Connect("join-a");
|
||||
secondClient.Connect("join-b");
|
||||
for (var attempt = 0; attempt < 40 && (!firstClient.Connected || !secondClient.Connected || server.Peers.Count != 2); attempt++)
|
||||
{
|
||||
server.ReceiveOnce();
|
||||
firstClient.ReceiveOnce();
|
||||
secondClient.ReceiveOnce();
|
||||
server.PollResends();
|
||||
firstClient.PollResends();
|
||||
secondClient.PollResends();
|
||||
Thread.Sleep(5);
|
||||
}
|
||||
|
||||
Assert.That(firstClient.Connected, Is.True);
|
||||
Assert.That(secondClient.Connected, Is.True);
|
||||
Assert.That(server.Peers, Has.Count.EqualTo(2));
|
||||
|
||||
firstClient.SendSchema("first-payload");
|
||||
secondClient.SendSchema("second-payload");
|
||||
CultNetRudpSocketServerFrame? firstFrame = null;
|
||||
CultNetRudpSocketServerFrame? secondFrame = null;
|
||||
for (var attempt = 0; attempt < 40 && (firstFrame == null || secondFrame == null); attempt++)
|
||||
{
|
||||
var frame = server.ReceiveOnce();
|
||||
if (frame != null)
|
||||
{
|
||||
var payload = Encoding.UTF8.GetString(frame.Frame.Payload);
|
||||
if (payload == "first-payload")
|
||||
{
|
||||
firstFrame = frame;
|
||||
}
|
||||
else if (payload == "second-payload")
|
||||
{
|
||||
secondFrame = frame;
|
||||
}
|
||||
}
|
||||
firstClient.ReceiveOnce();
|
||||
secondClient.ReceiveOnce();
|
||||
server.PollResends();
|
||||
firstClient.PollResends();
|
||||
secondClient.PollResends();
|
||||
Thread.Sleep(5);
|
||||
}
|
||||
|
||||
Assert.That(firstFrame, Is.Not.Null);
|
||||
Assert.That(secondFrame, Is.Not.Null);
|
||||
Assert.That(firstFrame!.Peer.RemoteEndPoint, Is.Not.EqualTo(secondFrame!.Peer.RemoteEndPoint));
|
||||
Assert.That(firstFrame.Frame.ChannelId, Is.EqualTo("schema"));
|
||||
Assert.That(secondFrame.Frame.ChannelId, Is.EqualTo("schema"));
|
||||
|
||||
server.SendSchema(firstFrame.Peer, "reply-a");
|
||||
server.SendSchema(secondFrame.Peer, "reply-b");
|
||||
var firstReply = firstClient.ReceiveSchema(TimeSpan.FromSeconds(1));
|
||||
var secondReply = secondClient.ReceiveSchema(TimeSpan.FromSeconds(1));
|
||||
|
||||
Assert.That(firstReply, Is.Not.Null);
|
||||
Assert.That(secondReply, Is.Not.Null);
|
||||
Assert.That(Encoding.UTF8.GetString(firstReply!), Is.EqualTo("reply-a"));
|
||||
Assert.That(Encoding.UTF8.GetString(secondReply!), Is.EqualTo("reply-b"));
|
||||
Assert.That(server.Profile.Transports[0].Protocol, Is.EqualTo("rudp"));
|
||||
Assert.That(server.Stats.FramesReceived, Is.EqualTo(2));
|
||||
Assert.That(server.Stats.FramesSent, Is.EqualTo(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RudpSocketTransport_ErgonomicHelpersCarryNamedChannels()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue