feat(network)!: add v2 framing, pooled buffers and bounded dispatch
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace ShrinkNetwork
|
||||
{
|
||||
public sealed class ShrinkLoopbackTransport : IShrinkNetworkAsyncTransport, IShrinkNetworkSessionControlTransport
|
||||
public sealed class ShrinkLoopbackTransport : IShrinkNetworkMemoryTransport, IShrinkNetworkSessionControlTransport
|
||||
{
|
||||
private readonly HashSet<long> _openedSessions = new();
|
||||
private ShrinkLoopbackTransport? _peer;
|
||||
@@ -73,5 +74,12 @@ namespace ShrinkNetwork
|
||||
_peer.OnEvent?.Invoke(ShrinkNetworkTransportEvent.Packet(sessionId, packetData));
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public UniTask SendAsync(long sessionId, ReadOnlyMemory<byte> packetData, CancellationToken cancellationToken = default)
|
||||
{
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
// Receivers may enqueue the event beyond this call; transfer a dedicated copy.
|
||||
return SendAsync(sessionId, packetData.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user