/// <summary>Returns a <code>SharedChannel</code> which supports the specified /// <code>profile</code> and calls back on the specified /// <code>DataListener</code>. Once it is no longer needed, call /// <code>release</code> on the <code>SharedChannel</code> /// to return it to the pool of available channels.</summary> /// <param name="profile">Name of profile for the requested /// <code>SharedChannel</code>.</param> /// <param name="listener"><code>DataListener</code> for the requested /// <code>SharedChannel</code>.</param> /// <returns>A <code>SharedChannel</code>.</returns> /// <seealso cref="MessageListener"></seealso> /// <seealso cref="SharedChannel"></seealso> /// <exception cref="BEEPException" /> /// <deprecated></deprecated> public virtual SharedChannel getSharedChannel(string profile, MessageListener listener) { lock (this) { SharedChannel sharedCh = null; bool found = false; lock (availableChannels) { for(int i=0;i<availableChannels.Count;i++) { sharedCh = (SharedChannel) availableChannels[i]; if (sharedCh.getProfile().Equals(profile)) { log.trace("Found an available channel for sharing"); availableChannels.RemoveAt(i); found = true; break; } } } // nothing found, so create one and return it if (!found) { sharedCh = new SharedChannel(this.session.startChannel(profile, listener), this); } // clean up channels that have expired garbageCollect(); if (log.isTraceEnabled()) { log.trace("Sharing channel number:" + sharedCh.Number); } return sharedCh; } }
/// <summary>Called from <code>SharedChannel</code>. Releases the sharedCh and adds /// it to the list of available SharedChannels.</summary> internal virtual void releaseSharedChannel(SharedChannel sharedCh) { // this channel is available to share lock (availableChannels) { availableChannels.Add(sharedCh); } garbageCollect(); }