public void AddConnection(long id, FrameConnection connection) { if (!_connectionReferences.TryAdd(id, new FrameConnectionReference(connection))) { throw new ArgumentException(nameof(id)); } }
public void AdaptedOutputPipeOptionsConfiguredCorrectly(long?maxRequestBufferSize, long expectedMaximumSizeLow, long expectedMaximumSizeHigh) { var serviceContext = new TestServiceContext(); serviceContext.ServerOptions.Limits.MaxResponseBufferSize = maxRequestBufferSize; var connectionLifetime = new FrameConnection(new FrameConnectionContext { ServiceContext = serviceContext }); Assert.Equal(expectedMaximumSizeLow, connectionLifetime.AdaptedOutputPipeOptions.MaximumSizeLow); Assert.Equal(expectedMaximumSizeHigh, connectionLifetime.AdaptedOutputPipeOptions.MaximumSizeHigh); Assert.Same(InlineScheduler.Default, connectionLifetime.AdaptedOutputPipeOptions.ReaderScheduler); Assert.Same(InlineScheduler.Default, connectionLifetime.AdaptedOutputPipeOptions.WriterScheduler); }
public FrameConnectionTests() { _pipeFactory = new PipeFactory(); _frameConnectionContext = new FrameConnectionContext { ConnectionId = "0123456789", ConnectionAdapters = new List <IConnectionAdapter>(), ConnectionInformation = new MockConnectionInformation { PipeFactory = _pipeFactory }, FrameConnectionId = long.MinValue, Input = _pipeFactory.Create(), Output = _pipeFactory.Create(), ServiceContext = new TestServiceContext { SystemClock = new SystemClock() } }; _frameConnection = new FrameConnection(_frameConnectionContext); }
private void UnrootedConnectionsGetRemovedFromHeartbeatInnerScope( string connectionId, FrameConnectionManager frameConnectionManager, Mock <IKestrelTrace> trace) { var frameConnection = new FrameConnection(new FrameConnectionContext { ServiceContext = new TestServiceContext(), ConnectionId = connectionId }); frameConnectionManager.AddConnection(0, frameConnection); var connectionCount = 0; frameConnectionManager.Walk(_ => connectionCount++); Assert.Equal(1, connectionCount); trace.Verify(t => t.ApplicationNeverCompleted(connectionId), Times.Never()); // Ensure frameConnection doesn't get GC'd before this point. GC.KeepAlive(frameConnection); }
private void WalkCallback(FrameConnection connection) { connection.Tick(_now); }
public bool TryGetConnection(out FrameConnection connection) { return(_weakReference.TryGetTarget(out connection)); }
public FrameConnectionReference(FrameConnection connection) { _weakReference = new WeakReference <FrameConnection>(connection); ConnectionId = connection.ConnectionId; }