コード例 #1
0
        /// <summary>
        /// Push to a specific user
        /// </summary>
        /// <param name="who"></param>
        /// <param name="message"></param>
        public static void PushToUser(string who, MessageDTO message, EasyShoppingHub hub)
        {
            IHubConnectionContext <dynamic> clients = GetClients(hub);

            foreach (var connectionId in _connections.GetConnections(who))
            {
                clients.Client(connectionId).addChatMessage(message);
            }
        }
コード例 #2
0
        public static void Show(string who, EasyShoppingHub hub)
        {
            IHubConnectionContext <dynamic> clients = GetClients(hub);
            IHubContext context = GlobalHost.ConnectionManager.GetHubContext <EasyShoppingHub>();

            foreach (var connectionId in _connections.GetConnections(who))
            {
                clients.Client(connectionId).showAll();
            }
        }
コード例 #3
0
 private static IHubConnectionContext <dynamic> GetClients(EasyShoppingHub EasyShoppingHub)
 {
     if (EasyShoppingHub == null)
     {
         return(GlobalHost.ConnectionManager.GetHubContext <EasyShoppingHub>().Clients);
     }
     else
     {
         return(EasyShoppingHub.Clients);
     }
 }
コード例 #4
0
        /// <summary>
        /// Push to list users
        /// </summary>
        /// <param name="who"></param>
        /// <param name="message"></param>
        public static void PushToUsers(string[] whos, MessageDTO message, EasyShoppingHub hub)
        {
            IHubConnectionContext <dynamic> clients = GetClients(hub);

            for (int i = 0; i < whos.Length; i++)
            {
                var who = whos[i];
                foreach (var connectionId in _connections.GetConnections(who))
                {
                    clients.Client(connectionId).addChatMessage(message);
                }
            }
        }
コード例 #5
0
        public static void PushToAllUsers(MessageDTO message, EasyShoppingHub hub)
        {
            IHubConnectionContext <dynamic> clients = GetClients(hub);

            clients.All.addAnnouncement(message);
        }