예제 #1
0
        public async Task Start(WsConnection webSocket, CancellationTokenSource cancellation)
        {
            _cancellation = cancellation;

            using var connection = await _connector.ConnectAsync(EndPoint);

            var token         = _cancellation.Token;
            var adapter       = SocketAdapter.Create(webSocket, connection);
            var receiveLoop   = ReceiveLoop(adapter, token);
            var handshakeLoop = KeepALiveLoop(adapter, token);

            // Create class to loop over taks until cancel or exception
            await new TaskRunner(new[] { receiveLoop, handshakeLoop }, token).Start();
        }
예제 #2
0
 public static SocketAdapter Create(WsConnection webSocket, SocketConnection socket)
 {
     return(new SocketAdapter(webSocket, socket));
 }
예제 #3
0
 public Task Start(WsConnection webSocket, CancellationTokenSource cancellation)
 {
     return(_policy.ExecuteAsync(() => _instance.Start(webSocket, cancellation)));
 }
예제 #4
0
 private SocketAdapter(WsConnection webSocket, SocketConnection socket)
 {
     WebSocket = webSocket;
     Socket    = socket;
 }