Example #1
0
        /// <summary>
        /// Get all rooms which this socket is in.
        /// </summary>
        /// <param name="socket">This socket</param>
        /// <returns>Room list</returns>
        public static Dictionary <string, IRoom> Rooms(this ISocket socket)
        {
            var rooms   = socket.GetNamespace().GetRooms();
            var inRooms = new Dictionary <string, IRoom>();

            foreach (var(key, value) in rooms)
            {
                if (value.Sockets.Exists(socket1 => socket == socket1))
                {
                    rooms.Add(key, value);
                }
            }

            return(inRooms);
        }
Example #2
0
 /// <summary>
 /// Leave a room.
 /// </summary>
 /// <param name="socket">The socket will left</param>
 /// <param name="room">The room's name that the socket left</param>
 public static void Leave(this ISocket socket, string room)
 {
     socket.GetNamespace().To(room).Remove(socket);
 }
Example #3
0
 /// <summary>
 /// Join to a room.
 /// </summary>
 /// <param name="socket">The socket will be joined to</param>
 /// <param name="room">The room's name that the socket will joined to</param>
 public static void Join(this ISocket socket, string room)
 {
     socket.GetNamespace().To(room).Add(socket);
 }