예제 #1
0
        public Tuple <bool, string> Notify(string username, NotifyData notification)
        {
            if (ws is null)
            {
                return(new Tuple <bool, string>(true, "ws undefiened"));
            }
            User user = UM.GetUser(username);

            //add notification's user
            notification.UserName = username;
            if (!user.LoggedStatus())
            {
                user.AddMessage(notification);
                //add message to db, thus user can get it later
                if (!user.IsGuest)
                {
                    DbManager.Instance.InsertUserNotification(AdapterCommunication.ConvertNotifyData(notification));
                }
            }
            else
            {
                ws.notify(username, notification);
            }

            return(new Tuple <bool, string>(true, ""));
        }
예제 #2
0
        public Tuple <bool, string> Notify(int store, NotifyData notification)
        {
            if (ws is null)
            {
                return(new Tuple <bool, string>(true, "ws undefiened"));
            }
            LinkedList <string> users;

            if (!StoreSubscribers.TryGetValue(store, out users))
            {
                return(new Tuple <bool, string>(false, "There is No Subscribers for the Store"));
            }
            foreach (string username in users)
            {
                User user = UM.GetUser(username);
                //add notification's user
                notification.UserName = username;
                if (!user.LoggedStatus())
                {
                    user.AddMessage(notification);
                    //add message to db, thus user can get it later
                    if (!user.IsGuest)
                    {
                        DbManager.Instance.InsertUserNotification(AdapterCommunication.ConvertNotifyData(notification));
                    }
                }
                else
                {
                    ws.notify(username, notification);
                }
            }
            return(new Tuple <bool, string>(true, ""));
        }