/// <summary>
        ///
        /// </summary>
        public bool RemoveClient(IArbiterSlimClient client)
        {
            List <IArbiterSlimClient> clientsHotSwap = _clientsHotSwap;

            int id = client.ArbiterSlimIndex;

            if (clientsHotSwap.Count <= id || id < 0)
            {
                SystemMonitor.OperationError("Failed to remove client from ArbiterSlim.");
                return(false);
            }

            if (clientsHotSwap[id].Client != client.Client)
            {
                SystemMonitor.OperationError("Client [" + client.Client.SubscriptionClientID.ToString() + "] does not belong to this arbiter with this ID.");
                return(false);
            }

            lock (this)
            {
                clientsHotSwap[id] = null;
                _idToIndexHotSwap[client.Client.SubscriptionClientID.Id.Guid] = -1;
            }

            client.OnRemoveFromArbiter();
            return(true);
        }
        /// <summary>
        ///
        /// </summary>
        public bool AddClient(IArbiterSlimClient client)
        {
            int index = -1;

            lock (this)
            {// We shall perform a swap of the clients collection, to ensure all operations
             // continue while we are doing the add of the client.

                if (GetClientIndexById(client.Client.SubscriptionClientID.Id) >= 0)
                {// Already added.
                    return(false);
                }

                // Since once deployed, collection is never modified, reading like this is safe.
                // Just make sure to not use _clients multiple times, rather grab a reference first.
                List <IArbiterSlimClient> clientsHotSwap = new List <IArbiterSlimClient>(_clientsHotSwap);
                clientsHotSwap.Add(client);
                index = clientsHotSwap.Count - 1;

                Dictionary <Guid, int> idToIndexHotSwap = new Dictionary <Guid, int>(_idToIndexHotSwap);
                // This type of assignment will also work with multiple entries.
                idToIndexHotSwap[client.Client.SubscriptionClientID.Id.Guid] = index;

                // Instant swaps.
                _clientsHotSwap   = clientsHotSwap;
                _idToIndexHotSwap = idToIndexHotSwap;
            }

            client.OnAddToArbiter(this, index);
            return(true);
        }
        /// <summary>
        ///
        /// </summary>
        public bool Send(int senderID, Envelope envelope)
        {
            if (_isDisposed)
            {// Possible to get disposed while operating here.
                return(false);
            }

            IArbiterSlimClient client = GetClientByIndex(envelope.ReceiverArbiterSlimIndex);

            if (client == null)
            {
                SystemMonitor.OperationError("Failed to find arbiter slim client [" + envelope.ReceiverArbiterSlimIndex.ToString() + "].");
                return(false);
            }

            return(client.Receive(envelope));
        }