示例#1
0
 public CopyOnWriteArraySet(ICollection collection)
 {
     this._array = new CopyOnWriteArray();
     foreach (object obj2 in collection)
     {
         this._array.Add(obj2);
     }
 }
 /// <summary>
 /// Creates a set containing all of the elements of the specified collection.
 /// </summary>
 /// <param name="collection"></param>
 public CopyOnWriteArraySet(ICollection collection)
 {
     _array = new CopyOnWriteArray();
     foreach (var obj in collection)
     {
         _array.Add(obj);
     }
 }
 /// <summary>
 /// Creates an empty set.
 /// </summary>
 public CopyOnWriteArraySet()
 {
     _array = new CopyOnWriteArray();
 }
 /// <summary>
 /// Creates a set containing all of the elements of the specified collection.
 /// </summary>
 /// <param name="collection"></param>
 public CopyOnWriteArraySet(ICollection collection)
 {
     _array = new CopyOnWriteArray();
     foreach (object obj in collection)
         _array.Add(obj);
 }
 /// <summary>
 /// Creates an empty set.
 /// </summary>
 public CopyOnWriteArraySet()
 {
     _array = new CopyOnWriteArray();
 }
示例#6
0
        /*
    internal void Disconnect(bool timeout)
    {
        lock (this.SyncRoot)
        {
            if (this.IsDisconnecting || this.IsDisconnected)
                return;
            try
            {
                SetIsDisconnecting(true);
                //restore context
                IConnection currentConnection = null;
                if (this.Connections != null && this.Connections.Count > 0)
                {
                    IEnumerator enumerator = this.Connections.GetEnumerator();
                    enumerator.MoveNext();
                    currentConnection = enumerator.Current as IConnection;
                }
                if (FluorineContext.Current == null)
                {
                    _TimeoutContext context = new _TimeoutContext(currentConnection, this);
                    //WebSafeCallContext.SetData(FluorineContext.FluorineContextKey, context);
                    try
                    {
                        // See if we're running in full trust
                        new SecurityPermission(PermissionState.Unrestricted).Demand();
                        WebSafeCallContext.SetData(FluorineContext.FluorineContextKey, context);
                    }
                    catch (SecurityException)
                    {
                        System.Web.HttpContext ctx = System.Web.HttpContext.Current;
                        if (ctx != null)
                            ctx.Items[FluorineContext.FluorineContextKey] = context;
                    }
                }
                _clientManager.RemoveSubscriber(this);
                // Unregister from all sessions.
                if (_sessions != null && _sessions.Count != 0)
                {
                    foreach (ISession session in _sessions)
                        UnregisterSession(session);
                }        
                //Invalidate associated MessageClient subscriptions.
                if (_messageClients != null)
                {
                    foreach (MessageClient messageClient in _messageClients)
                    {
                        messageClient.RemoveMessageClientDestroyedListener(this);
                        if (timeout)
                            messageClient.Timeout();
                        else
                            messageClient.Disconnect();
                    }
                    _messageClients.Clear();
                }
                //Notify destroy listeners.
                if (_destroyedListeners != null)
                {
                    foreach (IClientListener listener in _destroyedListeners)
                    {
                        listener.ClientDestroyed(this);
                    }
                }
                // Close any registered push handlers.
                if (_endpointPushHandlers != null && _endpointPushHandlers.Count != 0)
                {
                    foreach (IEndpointPushHandler handler in _endpointPushHandlers.Values)
                    {
                        handler.Close();
                    }
                    _endpointPushHandlers = null;
                }

                foreach (IConnection connection in this.Connections)
                {
                    if (timeout)
                        connection.Timeout();
                    connection.Close();
                }
            }
            catch(Exception ex)
            {
                if (log.IsErrorEnabled)
                    log.Error(string.Format("Disconnect Client {0}", this.Id), ex);
            }
            finally
            {
                SetIsDisconnecting(false);
                SetIsDisconnected(true);
            }
        }
    }
        */

        /*
        public IMessage[] GetPendingMessages(int waitIntervalMillis)
        {
            ArrayList messages = new ArrayList();
            try
            {
                SetIsPolling(true);
                do
                {
                    _clientManager.LookupClient(this._id);//renew

                    if (_messageClients != null)
                    {
                        foreach (MessageClient messageClient in _messageClients)
                        {
                            messageClient.Renew();
                            messages.AddRange(messageClient.GetPendingMessages());
                        }
                    }
                    if (waitIntervalMillis == 0)
                    {
                        return messages.ToArray(typeof(IMessage)) as IMessage[];
                    }
                    if (messages.Count > 0)
                    {
                        return messages.ToArray(typeof(IMessage)) as IMessage[];
                    }
                    System.Threading.Thread.Sleep(500);
                    waitIntervalMillis -= 500;
                    if (waitIntervalMillis <= 0)
                        SetIsPolling(false);
                }
                while (this.IsPolling && !this.IsInvalidating && !this.IsValid);
            }
            catch (Exception ex)
            {
                if (log.IsErrorEnabled)
                    log.Error(string.Format("GetPendingMessages Client {0}", this.Id), ex);
            }
            finally
            {
                SetIsPolling(false);
            }
            return messages.ToArray(typeof(IMessage)) as IMessage[];
        }
        */

        /// <summary>
        /// Adds a client destroy listener that will be notified when the client is destroyed.
        /// </summary>
        /// <param name="listener">The listener to add.</param>
        public void AddClientDestroyedListener(IClientListener listener)
        {
            if (listener != null)
            {
                if (_destroyedListeners == null)
                {
                    lock (this.SyncRoot)
                    {
                        if (_destroyedListeners == null)
                            _destroyedListeners = new CopyOnWriteArray();
                    }
                }
                _destroyedListeners.AddIfAbsent(listener);
            }
        }
示例#7
0
 internal IList GetMessageClients()
 {
     if (_messageClients == null)
     {
         lock (this.SyncRoot)
         {
             if (_messageClients == null)
                 _messageClients = new CopyOnWriteArray();
         }
     }
     return _messageClients;
 }
示例#8
0
        /// <summary>
        /// Associates a MessagClient (subscription) with the Session.
        /// </summary>
        /// <param name="messageClient">The MessageClient to associate with the session.</param>
        internal void RegisterMessageClient(IMessageClient messageClient)
        {
            if (_messageClients == null)
            {
                lock (this.SyncRoot)
                {
                    if (_messageClients == null)
                        _messageClients = new CopyOnWriteArray();
                }
            }

            if (_messageClients.AddIfAbsent(messageClient))
                messageClient.AddMessageClientDestroyedListener(this);
        }
示例#9
0
 /// <summary>
 /// Adds a session destroy listener that will be notified when the session is destroyed.
 /// </summary>
 /// <param name="listener">The listener to add.</param>
 public void AddSessionDestroyedListener(ISessionListener listener)
 {
     if (listener != null)
     {
         if (_sessionDestroyedListeners == null)
         {
             lock (this.SyncRoot)
             {
                 if (_sessionDestroyedListeners == null)
                     _sessionDestroyedListeners = new CopyOnWriteArray();
             }
         }
         _sessionDestroyedListeners.AddIfAbsent(listener);
     }
 }