Пример #1
0
        /// <summary>
        /// 服务获取通知
        /// </summary>
        /// <param name="toClient"></param>
        internal void ServiceSendNotification(ToClientServiceSendNotification toClient)
        {
            try
            {
                if (toClient.SendType == SendType.Call)
                {
                    if (!Resources.GetRes().CallNotifications.ContainsKey(toClient.RoomId.Value))
                    {
                        Resources.GetRes().CallNotifications.Add(toClient.RoomId.Value, true);
                    }
                    else
                    {
                        Resources.GetRes().CallNotifications[toClient.RoomId.Value] = true;
                    }

                    Notification.Instance.ActionSendFromService(null, toClient.RoomId.Value, "Call");
                }
                else if (toClient.SendType == SendType.Online || toClient.SendType == SendType.Offline)
                {
                    RoomModel model = Resources.GetRes().RoomsModel.Where(x => x.RoomId == toClient.RoomId).FirstOrDefault();

                    if (toClient.SendType == SendType.Online)
                    {
                        model.State = 1;
                    }
                    else if (toClient.SendType == SendType.Offline)
                    {
                        model.State = 0;
                    }

                    Notification.Instance.ActionSendFromService(null, toClient.RoomId.Value, null);
                }
                else if (toClient.SendType == SendType.FireOn || toClient.SendType == SendType.FireOff)
                {
                    Resources.GetRes().IsFireAlarmEnable = (toClient.SendType == SendType.FireOn ? true : false);
                    Notification.Instance.ActionSend(null, -1, null);
                }
                else if (toClient.SendType == SendType.ExtendInfo)
                {
                    Resources.GetRes().ExtendInfo = JsonConvert.DeserializeObject <ExtendInfo>(toClient.Model);
                    Notification.Instance.ActionSend(null, -2, null);
                }
            }
            catch (Exception ex)
            {
                ExceptionPro.ExpLog(ex);
            }
        }
Пример #2
0
 public void ServiceSendNotification(string ConnectionId, ToClientServiceSendNotification toClient)
 {
     Task.Run(() => ServiceHubContext.Instance.ServiceHub.Clients.Client(ConnectionId).ServiceSendNotification(toClient)).Wait();
 }