예제 #1
0
        public WebStoreOrderNotification NotifyOrder(WebStoreOrderNotification notification)
        {
            // statically access a hub locally - rather than creating a client
            var context = GlobalHost.ConnectionManager.GetHubContext <WebStoreNotificationHub>();

            // This works but you're repeating your logic
            //context.Clients.All.OnNotifyOrder(notification);

            // Instead we can create the hub and call its service logic by
            // passing in/injecting the active context
            var hub = new WebStoreNotificationHub(context);

            hub.NotifyOrder(notification);

            return(notification);
        }
 public void NotifyOrder(WebStoreOrderNotification notification)
 {
     _context.Clients.All.OnNotifyOrder(notification);
 }