Esempio n. 1
0
        public VideoController(
            IHostingEnvironment hostingEnvironment,
            IVideoService service,
            IHubContext <VideoHub, IVideoHub> videoHub,
            IHubContext <ManagementHub, IManagementHub> managementHub)
        {
            _videoPath     = $"{hostingEnvironment.WebRootPath}\\Videos";
            _service       = service;
            _videoHub      = videoHub;
            _managementHub = managementHub;
            var categories       = CategoryInfos();
            var clientIdentities = GetClientIdentities1();

            _service.Init(_videoPath, categories, clientIdentities);
            ManagementHub.AddNotifyEvent(
                (sender, args) =>
            {
                _managementHub.Clients.All.getOnlineUsers(Utility.VideoUtility.GetClientCount());
            }
                );
            VideoHub.AddConnectedEvent(
                (senger, args) =>
            {
                _service.AddClientIdentity(
                    args.Id, args.Ip, true);
                _managementHub.Clients.All.getOnlineUsers(Utility.VideoUtility.GetClientCount());
            });

            VideoHub.AddDisconnectedEvent((senger, args) =>
            {
                _service.AddClientIdentity(
                    args.Id, args.Ip, false);
                _managementHub.Clients.All.getOnlineUsers(Utility.VideoUtility.GetClientCount());
            });
        }
Esempio n. 2
0
        public VideoController(
            IVideoService videoService,
            IHubContext <VideoHub, IVideoHub> videoHub,
            IHubContext <ManagementHub, IManagementHub> managementHub)
        {
            _videoHub      = videoHub;
            _managementHub = managementHub;
            _videoService  = videoService;

            ManagementHub.AddNotifyEvent((sender, args) =>
            {
                OnlineUserChange();
            });

            VideoHub.AddConnectedEvent((senger, args) =>
            {
                ManagementHub.DoNotifyEvent();
            });

            VideoHub.AddDisconnectedEvent((senger, args) =>
            {
                ManagementHub.DoNotifyEvent();
            });
        }