コード例 #1
0
        public override Task OnDisconnected(bool stop)
        {
            UserDataDto user;
            var         events = new SignalREventHandlers(Context.QueryString["access_token"]);

            if (_users.Keys.Contains(Context.ConnectionId))
            {
                Groups.Remove(Context.ConnectionId, _users[Context.ConnectionId].GroupName);

                if (_users.TryRemove(Context.ConnectionId, out user))
                {
                    if (!user.GroupName.Contains("PulseServer#"))
                    {
                        ProcessNotification(Context, ProcessType.Disconnected, KioskStatus.offline, user.MachineId, user.SystemName, user.GroupName);
                        Clients.Group(user.GroupName).OnDisconnected(user.MachineId);
                        AsyncHelper.RunSync(() => events.TriggerSystemEventAsync(new SystemEventArgs {
                            Action      = ActionType.Disconnected,
                            Description = "Disconnected",
                            MachineId   = user.MachineId,
                            MachineName = user.SystemName,
                            Status      = SystemEventStatus.Hight,
                        }));
                    }
                }
            }

            return(base.OnDisconnected(false));
        }
コード例 #2
0
        public void SendDeviceControl(string machineId, string controlType)
        {
            var userData = FindUserDataByMachineId(machineId);
            var events   = new SignalREventHandlers(Context.QueryString["access_token"]);

            if (userData != null)
            {
                ProcessDevicesControlMessage(userData.ConnectionId, controlType);
                AsyncHelper.RunSync(() => events.TriggerSystemEventAsync(new SystemEventArgs
                {
                    Action      = controlType == "shutdown" ? ActionType.ShutDown : ActionType.Restart,
                    Description = controlType == "shutdown" ? Enum.GetName(typeof(ActionType), 1) : Enum.GetName(typeof(ActionType), 0),
                    MachineId   = machineId,
                    MachineName = userData.SystemName,
                    Status      = SystemEventStatus.Critical
                }));
            }
        }