/// <summary> /// Completes an asynchronous operation initiated by <see cref="BeginRequest(Message,AsyncCallback,object)" /> /// or <see cref="BeginRequest(Message,TimeSpan,AsyncCallback,object)" />. /// </summary> /// <param name="result">The <see cref="IAsyncResult" /> instance returned by <b>BeginRequest()</b>.</param> /// <returns>The correlated response message.</returns> public Message EndRequest(IAsyncResult result) { try { WcfEnvelopeMsg replyMsg; replyMsg = (WcfEnvelopeMsg)ChannelHost.Router.EndQuery(result); if (!base.CanAcceptMessages) { // This is a bit of a hack to simulate aborting pending // requests when the channel is closed. throw ServiceModelHelper.CreateObjectDisposedException(this); } // Decode the reply using (BlockStream bs = new BlockStream((Block)replyMsg.Payload)) return(encoder.ReadMessage(bs, ServiceModelHelper.MaxXmlHeaderSize)); } catch (Exception e) { throw ServiceModelHelper.GetCommunicationException(e); } }
/// <summary> /// Invoked during the transition of a communication object into the closed state. /// </summary> /// <remarks> /// The base class implementation calls <see cref="TerminatePendingOperations" /> and /// the associated channel manager's <see cref="ILillTekChannelManager.OnChannelCloseOrAbort" /> method. /// </remarks> protected override void OnClosed() { Exception e = ServiceModelHelper.CreateObjectDisposedException(this); TerminatePendingOperations(e); Cleanup(); channelManager.OnChannelCloseOrAbort(this, e); base.OnClosed(); }
/// <summary> /// Internal event handler. /// </summary> /// <param name="timeout"></param> /// <param name="callback"></param> /// <param name="state"></param> /// <returns></returns> protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { AsyncResult ar; Cleanup(ServiceModelHelper.CreateObjectDisposedException(this)); timeout = ServiceModelHelper.ValidateTimeout(timeout); ar = new AsyncResult(null, callback, state); ar.Started(ServiceModelHelper.AsyncTrace); ar.Notify(); return(ar); }
/// <summary> /// Called by derived classes when a new channel is created. /// </summary> /// <param name="channel">The new channel.</param> public virtual void AddChannel(LillTekChannelBase channel) { using (TimedLock.Lock(this)) { if (channels == null) { throw ServiceModelHelper.CreateObjectDisposedException(this); } channels.Add(channel.ID, (TInternal)channel); } }
/// <summary> /// Internal event handler. /// </summary> /// <param name="timeout"></param> protected override void OnClose(TimeSpan timeout) { Cleanup(ServiceModelHelper.CreateObjectDisposedException(this)); }
/// <summary> /// Internal event handler /// </summary> protected override void OnClosing() { Cleanup(ServiceModelHelper.CreateObjectDisposedException(this)); base.OnClosing(); }