public InMemoryConnection CreateConnection(Encoding encoding = null) { var transportConnection = new InMemoryTransportConnection(_memoryPool, Context.Log, Context.Scheduler); _transportFactory.AddConnection(transportConnection); return(new InMemoryConnection(transportConnection, encoding)); }
public async ValueTask <ConnectionContext> ConnectAsync(EndPoint endpoint, CancellationToken cancellationToken = default) { var listener = _hub.GetConnectionListenerFactory(endpoint); if (listener is null) { throw new ConnectionFailedException($"Unable to connect to endpoint {endpoint} because no such endpoint is currently registered."); } var connectionContext = InMemoryTransportConnection.Create( _memoryPool.Pool, _loggerFactory.CreateLogger <InMemoryTransportConnection>(), _localEndpoint, endpoint); await listener.ConnectAsync(connectionContext).WithCancellation(cancellationToken); return(connectionContext); }
public InMemoryConnection(InMemoryTransportConnection transportConnection, Encoding encoding) : base(new DuplexPipeStream(transportConnection.Output, transportConnection.Input), encoding) { TransportConnection = transportConnection; }