private static (IConnectionListenerFactory, IConnectionFactory, EndPoint, EndPoint) GetHttp2Transport(ILoggerFactory loggerFactory) { // This is an http/2 transport based on kestrel and httpclient, each connection is mapped to an HTTP/2 stream var serverFactory = new Http2ConnectionListenerFactory(loggerFactory); var clientFactory = new Http2ConnectionFactory(); var endPoint = new UriEndPoint(new Uri("https://localhost:5003")); return(serverFactory, clientFactory, endPoint, endPoint); }
private static (IConnectionListenerFactory, IConnectionFactory, EndPoint, EndPoint) GetWebSocketTransport(ILoggerFactory loggerFactory) { // This is an websockets transport based on Kestrel and ClientWebSocket var serverFactory = new WebSocketConnectionListenerFactory(loggerFactory); var clientFactory = new WebSocketConnectionFactory(loggerFactory); var endPoint = new UriEndPoint(new Uri("https://localhost:5004")); return(serverFactory, clientFactory, endPoint, endPoint); }
public async Task StartAsync(CancellationToken cancellationToken) { var f = new StompWebSocketConnectionFactory(c => { c.Credentials = new NetworkCredential("admin", "admin"); }, logger); var e = new UriEndPoint(new Uri("ws://localhost:44112/websockets/messaging/websocket")); connection = await f.OpenAsync(e, cancellationToken); transaction = await connection.BeginAsync(cancellationToken : cancellationToken); cts = new CancellationTokenSource(); run = Task.Run(() => RunAsync(cts.Token)); }
public HttpClientProtocol(ConnectionContext connection) { _connection = connection; _reader = connection.CreateReader(); (string host, int port) = connection.RemoteEndPoint switch { UriEndPoint uriEndPoint => (uriEndPoint.Uri.Host, uriEndPoint.Uri.Port), IPEndPoint ip => (ip.Address.ToString(), ip.Port), _ => throw new NotSupportedException($"{connection.RemoteEndPoint} not supported") }; _messageWriter = new Http1RequestMessageWriter(host, port); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { var clientFactory = new WebSocketConnectionFactory(_loggerFactory); var clientEndPoint = new UriEndPoint(new Uri("https://localhost:5003")); var connection = await clientFactory.ConnectAsync(clientEndPoint); Console.WriteLine($"Connected to {clientEndPoint}"); Console.WriteLine("Echo server running, type into the console"); _ = Console.OpenStandardInput().CopyToAsync(connection.Transport.Output, stoppingToken); await connection.Transport.Input.CopyToAsync(Console.OpenStandardOutput(), stoppingToken); }
// Start is called before the first frame update void Start() { var endpoint = new UriEndPoint(new Uri("https://localhost:44340/rfch")); MyLoggerFactory loggerFactory = new MyLoggerFactory(); _connection = new HubConnection( new HttpConnectionFactory(new MyOptions(), loggerFactory), new JsonHubProtocol(), endpoint, new MyServiceProvider(), loggerFactory); _connection.StartAsync().ConfigureAwait(false); }