/// <summary> /// Create the session from the broker launcher uri /// </summary> /// <param name="uri">The broker launcher uri</param> protected virtual void BeginCreateSession(string uri) { SessionBase.TraceSource.TraceEvent(TraceEventType.Verbose, 0, "[Session:{0}] Start create broker against uri: {1}", this.sessionid, uri); BrokerLauncherClient brokerLauncher = new BrokerLauncherClient(new Uri(uri), this.StartInfo, this.binding); brokerLauncher.BeginCreate(this.StartInfo.Data, this.sessionid, this.CreateCallback, brokerLauncher); }
/// <summary> /// End the async operation. /// </summary> /// <param name="ar">the async result</param> /// <returns>the session info</returns> protected virtual BrokerInitializationResult EndCreateSession(IAsyncResult ar) { BrokerLauncherClient brokerLauncher = (BrokerLauncherClient)ar.AsyncState; try { return(brokerLauncher.EndCreate(ar)); } finally { Utility.SafeCloseCommunicateObject(brokerLauncher); } }
/// <summary> /// This method closes the session async with the given ID /// </summary> /// <param name="headNode">Headnode name</param> /// <param name="sessionId">The ID of the session to be closed</param> /// <param name="binding">indicting the binding</param> /// <param name="isAadUser">If the session is belong to a AAD user</param> /// <param name="token">The cancellation token.</param> public static async Task CloseSessionAsync(string headNode, string sessionId, Binding binding, bool isAadUser, CancellationToken token) { Utility.ThrowIfEmpty(headNode, "headNode"); SessionLauncherClient client = null; BrokerLauncherClient broker = null; string headNodeMachine = await TelepathyContext.GetOrAdd(headNode).ResolveSessionLauncherNodeAsync().ConfigureAwait(false); try { client = new SessionLauncherClient(headNodeMachine, binding, isAadUser); client.InnerChannel.OperationTimeout = GetTimeout(DateTime.MaxValue); // TODO: need to change the endpoint prefix for https SessionInfo info = null; if (binding is NetTcpBinding) { info = Utility.BuildSessionInfoFromDataContract(await client.GetInfoAsync(SessionLauncherClient.EndpointPrefix, sessionId).ConfigureAwait(false)); } #if !net40 else if (binding is BasicHttpBinding || binding is NetHttpBinding || binding is NetHttpsBinding) { info = Utility.BuildSessionInfoFromDataContract(await client.GetInfoAsync(SessionLauncherClient.HttpsEndpointPrefix, sessionId).ConfigureAwait(false)); } #endif broker = new BrokerLauncherClient(info, binding, new Uri(info.BrokerLauncherEpr)); broker.InnerChannel.OperationTimeout = GetTimeout(DateTime.MaxValue); broker.Close(sessionId); } catch (FaultException <SessionFault> e) { throw Utility.TranslateFaultException(e); } finally { if (client != null) { Utility.SafeCloseCommunicateObject(client); } if (broker != null) { Utility.SafeCloseCommunicateObject(broker); } } }
/// <summary> /// Override BeginCreateSession to create persistant session /// </summary> /// <param name="uri">the uri to the broker launcher</param> protected override void BeginCreateSession(string uri) { BrokerLauncherClient brokerLauncher = new BrokerLauncherClient(new Uri(uri), this.StartInfo, this.binding); brokerLauncher.BeginCreateDurable(this.StartInfo.Data, this.SessionId, CreateCallback, brokerLauncher); }