/// <summary> /// Opens the underlying connection. /// </summary> /// <param name="transport"></param> /// <param name="cancellationToken"></param> /// <returns></returns> protected async ValueTask <StompConnection> OpenAsync(StompTransport transport, CancellationToken cancellationToken) { var connection = new StompConnection(transport, options, logger); await connection.OpenAsync(cancellationToken); await connection.ConnectAsync(null, null, null, null, cancellationToken); return(connection); }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="connection"></param> /// <param name="id"></param> /// <param name="reader"></param> /// <param name="completeAsync"></param> public StompSubscription(StompConnection connection, string id, ChannelReader <StompFrame> reader, Func <Exception, ValueTask> completeAsync) { this.connection = connection ?? throw new ArgumentNullException(nameof(connection)); this.id = id ?? throw new ArgumentNullException(nameof(id)); this.reader = reader ?? throw new ArgumentNullException(nameof(reader)); this.completeAsync = completeAsync ?? throw new ArgumentNullException(nameof(completeAsync)); // when the reader is complete, the connection must be down, and we should indicate to cancel message processing var cts = new CancellationTokenSource(); reader.Completion.ContinueWith(t => cts.Cancel()); cancellationToken = cts.Token; }
/// <summary> /// Initializes a new instance. /// </summary> /// <param name="connection"></param> /// <param name="id"></param> public StompTransaction(StompConnection connection, string id) { this.connection = connection ?? throw new ArgumentNullException(nameof(connection)); this.id = id ?? throw new ArgumentNullException(nameof(id)); }