public void Process(AttachContext attachContext) { if (!attachContext.Attach.Role) { attachContext.Complete(new Error() { Condition = ErrorCode.NotAllowed, Description = "Only receiver link is allowed." }); return; } string address = ((Source)attachContext.Attach.Source).Address; if (!string.Equals("$monitoring", address, StringComparison.OrdinalIgnoreCase)) { attachContext.Complete(new Error() { Condition = ErrorCode.NotFound, Description = "Cannot find address " + address }); return; } Console.WriteLine("A client has connected. LinkName " + attachContext.Attach.LinkName); attachContext.Complete(new MonitoringLinkEndpoint(attachContext.Link), 0); }
async Task ProcessAsync(AttachContext attachContext) { // simulating an async operation required to complete the task await Task.Delay(100); if (attachContext.Attach.LinkName == "") { // how to fail the attach request attachContext.Complete(new Error() { Condition = ErrorCode.InvalidField, Description = "Empty link name not allowed." }); } else if (attachContext.Link.Role) { attachContext.Complete(new IncomingLinkEndpoint(), 300); } else { attachContext.Complete(new OutgoingLinkEndpoint(), 0); } }
async Task ProcessAsync(AttachContext attachContext) { // simulating an async operation required to complete the task await Task.Delay(100); if (attachContext.Attach.LinkName == "") { // how to fail the attach request attachContext.Complete(new Error() { Condition = ErrorCode.InvalidField, Description = "Empty link name not allowed." }); } else if (attachContext.Link.Role) { var target = attachContext.Attach.Target as Target; if (target != null) { if (target.Address == "slow-queue") { // how to do manual link flow control new SlowLinkEndpoint(attachContext); } else if (target.Address == "shared-queue") { // how to do flow control across links this.sharedLinkEndpoint.AttachLink(attachContext); } else { // default link flow control attachContext.Complete(new IncomingLinkEndpoint(), 300); } } } else { attachContext.Complete(new OutgoingLinkEndpoint(), 0); } }
public void Process(AttachContext attachContext) { if (attachContext.Link.Role && ((Target)attachContext.Attach.Target).Address == Name) { attachContext.Complete(new IncomingLinkEndpoint(), 30); } else { attachContext.Complete(new Error() { Condition = ErrorCode.NotImplemented }); } }
public void Process(AttachContext attachContext) { if (this.OnLinkAttached != null) { this.OnLinkAttached(attachContext.Link); } attachContext.Complete( this.factory != null ? this.factory(attachContext.Link) : new TestLinkEndpoint(), attachContext.Attach.Role ? 0 : 30); }
public void AttachLink(AttachContext attachContext) { this.semaphore.WaitAsync(30000).ContinueWith( t => { if (!t.Result) { attachContext.Complete(new Error() { Condition = ErrorCode.ResourceLimitExceeded }); } else { this.semaphore.Release(); attachContext.Complete(this, 1); } }); }
public SlowLinkEndpoint(AttachContext attachContext) { this.link = attachContext.Link; this.cts = new CancellationTokenSource(); link.Closed += (o, e) => this.cts.Cancel(); attachContext.Complete(this, 0); this.link.SetCredit(1, false, false); }
public void Process(AttachContext attachContext) { attachContext.Complete(new TestLinkEndpoint(), attachContext.Attach.Role ? 0 : 30); }