Exemple #1
0
        /// <summary>
        /// Aggregates the given range of Rooms by performing a 'union' operation on it.
        /// This means that the returned WebSocketRoom is one that contains all the WebSocketClients
        /// contained in all the rooms param without duplicates
        /// </summary>
        /// <param name="rooms">The range of WebSocketRoom objects to aggregate</param>
        /// <returns>
        /// A new WebSocketRoom containing all the contents of the WebSocketRooms
        /// in the Rooms param without duplicates
        /// </returns>
        /// <remark>
        /// If parameter rooms is
        /// </remark>
        public static WebSocketRoom Aggregate(IEnumerable <WebSocketRoom> rooms)
        {
            if (rooms == null)
            {
                return(new WebSocketRoom());
            }

            int nbRooms = rooms.Count();

            if (nbRooms == 0)
            {
                return(new WebSocketRoom());
            }
            if (nbRooms == 1)
            {
                return(rooms.ElementAt(0));
            }

            WebSocketRoom aggregate = rooms.ElementAt(0);

            for (int i = 1; i <  nbRooms; i++)
            {
                aggregate.Union(rooms.ElementAt(i));
            }

            return(aggregate);
        }
Exemple #2
0
 public WebSocketClientEnumerator(WebSocketRoom room)
 {
     this.room = room;
     curIndex  = -1;
     curCli    = default(WebSocketClient);
 }