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(); }
public static SocketAdapter Create(WsConnection webSocket, SocketConnection socket) { return(new SocketAdapter(webSocket, socket)); }
public Task Start(WsConnection webSocket, CancellationTokenSource cancellation) { return(_policy.ExecuteAsync(() => _instance.Start(webSocket, cancellation))); }
private SocketAdapter(WsConnection webSocket, SocketConnection socket) { WebSocket = webSocket; Socket = socket; }