Ejemplo n.º 1
0
        /// <summary>
        /// Called internally when an existing link session is closed.
        /// </summary>
        internal protected void OnLinkSessionDisconnectedInternal(int handle, object context)
        {
            Trace.Info("{0} disconnected {1} {2}", Name, handle, context);

            if (handle == 0)
            {
                return;
            }

            // Release the link session handle.
            LinkHandlePool.Release(handle);

            var session = (LinkSession)context;

            session.Connected = false;

            try
            {
                OnSessionDisconnectedInternal(handle, context);
            }
            catch (ObjectDisposedException)
            {
                // already disposed
                // TODO need to be improved
            }

            Hub.Post(new LinkSessionDisconnected {
                LinkName = Name,
                Handle   = handle,
                Context  = context
            });
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Removes the specified handle from the known peers.
 /// </summary>
 public void RemoveHandle(int handle)
 {
     using (new UpgradeableReadLock(rwlock))
     {
         EndPoint endPoint;
         if (!map.TryGetValue(handle, out endPoint))
         {
             return;
         }
         using (new WriteLock(rwlock))
         {
             map.Remove(handle);
             reverseMap.Remove(endPoint);
         }
     }
     LinkHandlePool.Release(handle);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes the specified remote end point from the known peers.
        /// </summary>
        public void RemoveEndPoint(EndPoint endPoint)
        {
            int handle;

            using (new UpgradeableReadLock(rwlock))
            {
                if (!reverseMap.TryGetValue(endPoint, out handle))
                {
                    return;
                }
                using (new WriteLock(rwlock))
                {
                    map.Remove(handle);
                    reverseMap.Remove(endPoint);
                }
            }
            LinkHandlePool.Release(handle);
        }