static void OnReceiverClose(IAsyncResult result) { RequestResponseAmqpLink thisPtr = (RequestResponseAmqpLink)result.AsyncState; thisPtr.OnOperationComplete(thisPtr.receiver, result, false); }
static void OnSenderOpen(IAsyncResult result) { RequestResponseAmqpLink thisPtr = (RequestResponseAmqpLink)result.AsyncState; thisPtr.OnOperationComplete(thisPtr.sender, result, true); }
RequestResponseAmqpLink EndCreateCbsLink(IAsyncResult result) { RequestResponseAmqpLink link = OpenCbsRequestResponseLinkAsyncResult.End(result).Link; return(link); }
void CloseLink(RequestResponseAmqpLink link) { link.Session.SafeClose(); }
protected override IEnumerator <AsyncStep> GetAsyncSteps() { string address = CbsConstants.CbsAddress; while (this.RemainingTime() > TimeSpan.Zero) { try { AmqpSessionSettings sessionSettings = new AmqpSessionSettings() { Properties = new Fields() }; this.session = new AmqpSession(this.connection, sessionSettings, this); connection.AddSession(session, null); } catch (InvalidOperationException exception) { this.Complete(exception); yield break; } yield return(this.CallAsync( (thisPtr, t, c, s) => thisPtr.session.BeginOpen(t, c, s), (thisPtr, r) => thisPtr.session.EndOpen(r), ExceptionPolicy.Continue)); Exception lastException = this.LastAsyncStepException; if (lastException != null) { AmqpTrace.Provider.AmqpOpenEntityFailed(this.connection, this.session, string.Empty, address, lastException.Message); this.session.Abort(); this.Complete(lastException); yield break; } AmqpLinkSettings settings = new AmqpLinkSettings(); settings.AddProperty(CbsConstants.TimeoutName, (uint)this.RemainingTime().TotalMilliseconds); settings.Target = new Target() { Address = address }; settings.Source = new Source() { Address = address }; settings.InitialDeliveryCount = 0; settings.TotalLinkCredit = 50; settings.AutoSendFlow = true; settings.SettleType = SettleMode.SettleOnSend; this.Link = new RequestResponseAmqpLink(this.session, settings); yield return(this.CallAsync( (thisPtr, t, c, s) => thisPtr.Link.BeginOpen(t, c, s), (thisPtr, r) => thisPtr.Link.EndOpen(r), ExceptionPolicy.Continue)); lastException = this.LastAsyncStepException; if (lastException != null) { AmqpTrace.Provider.AmqpOpenEntityFailed(this.connection, this.Link, this.Link.Name, address, lastException.Message); this.session.SafeClose(); this.Link = null; this.Complete(lastException); yield break; } AmqpTrace.Provider.AmqpOpenEntitySucceeded(this.connection, this.Link, this.Link.Name, address); yield break; } if (this.session != null) { this.session.SafeClose(); } this.Complete(new TimeoutException(AmqpResources.GetString(AmqpResources.AmqpTimeout, this.OriginalTimeout, address))); }