private static bool OperationComplete(IAsyncResult asyncResult) { AcceptMessageSessionForNamespaceAsyncResult asyncState = (AcceptMessageSessionForNamespaceAsyncResult)asyncResult.AsyncState; Message message = asyncState.MessagingFactory.Channel.EndRequest(asyncResult); AcceptMessageSessionForNamespaceResponseCommand body = message.GetBody <AcceptMessageSessionForNamespaceResponseCommand>(); SessionState sessionState = body.SessionState; MessageCollection messages = body.Messages; DateTime lockedUntilUtc = body.LockedUntilUtc; LinkInfo linkInfo = new LinkInfo() { ConnectionId = asyncState.MessagingFactory.ConnectionId, EntityName = body.EntityPath, IsSessionReceiver = true, LinkId = body.LinkId, ReceiveMode = asyncState.receiveMode, LinkType = LinkType.Receive, SessionId = body.SessionId }; LinkInfo linkInfo1 = linkInfo; CreateLinkSettings createLinkSetting = new CreateLinkSettings(asyncState.MessagingFactory, body.EntityPath, body.EntityPath, linkInfo1, null); SbmpMessageReceiver sbmpMessageReceiver = new SbmpMessageReceiver(createLinkSetting.EntityName, false, createLinkSetting.MessagingFactory, createLinkSetting.MessageCreator, createLinkSetting.ControlMessageCreator, createLinkSetting.LinkInfo, false, asyncState.MessagingFactory.RetryPolicy.Clone(), messages); sbmpMessageReceiver.Open(); asyncState.result = new SbmpMessageSession(body.SessionId, lockedUntilUtc, sessionState, sbmpMessageReceiver); return(true); }
public AcceptMessageSessionAsyncResult(SbmpMessagingFactory messagingFactory, string entityName, string sessionId, MessagingEntityType?entityType, ReceiveMode receiveMode, int prefetchCount, Lazy <SbmpMessageCreator> controlMessageCreator, RetryPolicy retryPolicy, TimeSpan serverWaitTime, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.prefetchCount = prefetchCount; this.sessionId = sessionId; this.MessagingFactory = messagingFactory; this.retryPolicy = retryPolicy ?? messagingFactory.RetryPolicy.Clone(); LinkInfo linkInfo = new LinkInfo() { LinkId = messagingFactory.GetNextLinkId(), ConnectionId = messagingFactory.ConnectionId, LinkType = LinkType.Receive, IsSessionReceiver = true, ReceiveMode = receiveMode, EntityName = entityName, EntityType = entityType }; this.createLinkSettings = new CreateLinkSettings(messagingFactory, entityName, entityName, linkInfo, controlMessageCreator); AcceptMessageSessionCommand acceptMessageSessionCommand = new AcceptMessageSessionCommand() { SessionId = this.sessionId, Timeout = serverWaitTime, OperationTimeout = timeout, PrefetchCount = this.prefetchCount }; AcceptMessageSessionCommand acceptMessageSessionCommand1 = acceptMessageSessionCommand; string linkId = null; if (this.createLinkSettings.ControlMessageCreator != null && !string.IsNullOrWhiteSpace(this.createLinkSettings.ControlMessageCreator.Value.LinkInfo.LinkId)) { linkId = this.createLinkSettings.ControlMessageCreator.Value.LinkInfo.LinkId; } RequestInfo requestInfo = new RequestInfo() { ServerTimeout = new TimeSpan?(acceptMessageSessionCommand1.Timeout), SessionId = acceptMessageSessionCommand1.SessionId }; RequestInfo requestInfo1 = requestInfo; Message message = this.createLinkSettings.MessageCreator.CreateWcfMessage("http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpMessageReceiver/AcceptMessageSession", acceptMessageSessionCommand1, linkId, this.retryPolicy, null, requestInfo1); if (base.SyncContinue(this.MessagingFactory.Channel.BeginRequest(message, SbmpProtocolDefaults.BufferTimeout(timeout, this.MessagingFactory.GetSettings().EnableAdditionalClientTimeout), base.PrepareAsyncCompletion(AcceptMessageSessionAsyncResult.operationComplete), this))) { base.Complete(true); } }
public AcceptMessageSessionBrowserAsyncResult(SbmpBrowsableMessageSession messageSession, SbmpMessagingFactory messagingFactory, MessagingEntityType?entityType, ReceiveMode receiveMode, int prefetchCount, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state) { this.messageSession = messageSession; this.sessionId = messageSession.SessionId; this.MessagingFactory = messagingFactory; string path = messageSession.Path; LinkInfo linkInfo = new LinkInfo() { LinkId = messagingFactory.GetNextLinkId(), ConnectionId = messagingFactory.ConnectionId, LinkType = LinkType.Receive, IsSessionReceiver = true, ReceiveMode = receiveMode, EntityName = path, EntityType = entityType, SessionId = messageSession.SessionId }; this.createLinkSettings = new CreateLinkSettings(messagingFactory, path, path, linkInfo, null); AcceptMessageSessionCommand acceptMessageSessionCommand = new AcceptMessageSessionCommand() { SessionId = this.sessionId, Timeout = timeout, PrefetchCount = prefetchCount, IsSessionBrowser = true }; AcceptMessageSessionCommand acceptMessageSessionCommand1 = acceptMessageSessionCommand; RequestInfo requestInfo = new RequestInfo() { ServerTimeout = new TimeSpan?(acceptMessageSessionCommand1.Timeout), SessionId = acceptMessageSessionCommand1.SessionId }; RequestInfo requestInfo1 = requestInfo; Message message = this.createLinkSettings.MessageCreator.CreateWcfMessage("http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpMessageReceiver/AcceptMessageSession", acceptMessageSessionCommand1, null, this.messageSession.RetryPolicy, null, requestInfo1); if (base.SyncContinue(this.MessagingFactory.Channel.BeginRequest(message, SbmpProtocolDefaults.BufferTimeout(timeout, this.MessagingFactory.GetSettings().EnableAdditionalClientTimeout), base.PrepareAsyncCompletion(AcceptMessageSessionBrowserAsyncResult.operationComplete), this))) { base.Complete(true); } }