public async Task <Connection> Connect(ReWorkClientRole role) { var cts = new CancellationTokenSource(); var tConnection = await _transportManager.ConnectAsync(role, cts.Token); var connection = _factory.Create(Guid.Empty.ToString(), tConnection, this); //once again, just fire and forget, and use the CancellationToken //to signal to the "forgotten" async invocation. connection.Authorize(); connection.ProcessCommandsAsync(cts.Token); await connection.Send(new InitiateHandshakeMessage()); return(connection); }
public Task <ITransportConnection> ConnectAsync(ReWorkClientRole role, CancellationToken ctx) { var client = new TcpClient(role.Host, role.Port); return(Task.FromResult(new ReworkTcpTransport(client, _commandConverter, _protocol) as ITransportConnection)); }
public Connection Start(ReWorkClientRole role) { return(Start().Connect(role).ConfigureAwait(false).GetAwaiter().GetResult()); }