Ejemplo n.º 1
0
        public async Task NotifyTimetableChangedAsync(int doctorId, DateTime date)
        {
            ICollection <ObserverInfo> observers;

            if (TimetableObservers.TryGetValue(doctorId, out observers))
            {
                var sessions = observers.Where(info => info.Date.Date == date.Date)
                               .Select(observer => observer.ObserverIdentifier).ToList();

                await ConnectionContext.Clients(sessions).TimetableChanged(doctorId, date);
            }
        }
Ejemplo n.º 2
0
        public void MsgProcess(ClientMsgPackEntity value, IHubCallerConnectionContext <dynamic> clients = null, string connectionId = "")
        {
            Task <bool> ts = new Task <bool>((arg) =>
            {
                bool ret = ConvertUtil.ConvertObjectToBool(arg, false);
                try
                {
                    if (value != null)
                    {
                        NewPushMsgPack newMsgPack = JsonUtil <NewPushMsgPack> .Deserialize(value.mp_cotent.ToString());
                        if (newMsgPack != null)
                        {
                            List <string> connIds = RedisHelper.Hash_Get <List <string> >(Constant.RedisClusterConn, Constant.ClientConnKey, newMsgPack.uid);
                            if (connIds != null && connIds.Any())
                            {
                                if (clients != null)
                                {
                                    clients.Clients(connIds).Push(newMsgPack.resdata);
                                    ret = true;
                                }
                            }
                        }
                    }
                }
                catch { }
                return(ret);
            }, false);

            ts.Start();
            ts.ContinueWith(t =>
            {
                clients.Client(connectionId).Push(ts.Result ? "推送消息到客户端成功!" : "推送消息到客户端失败!");
            });

            clients.Client(connectionId).Push("服务端接受到消息!");
        }
 public dynamic Clients(IList <string> connectionIds)
 {
     return(_clients.Clients(connectionIds));
 }