Beispiel #1
0
 public int AddSubscriber(Subscriber subscriber)
 {
     var coll = _database.GetCollection<Subscriber>(SubscribersKey);
     RemovePhoneSubscription(subscriber.DeviceId);
     coll.Save(subscriber);
     return (int) coll.Count();
 }
Beispiel #2
0
 public bool IsSubscribed(Subscriber subscriber)
 {
     var subscriberInStore = GetSubscriber(subscriber.DeviceId);
     return subscriberInStore != null;
 }
Beispiel #3
0
 public int GetSubscriberPosition(Subscriber subscriber)
 {
     var subscribers = GetSubscribers();
     return subscribers.FindIndex(y => y.DeviceId == subscriber.DeviceId) + 1;
 }
Beispiel #4
0
 public int IsPhoneSubscribed(string deviceId, string channelURI)
 {
     var subscriber = new Subscriber { ChannelURI = channelURI, DeviceId = deviceId};
     return _store.IsSubscribed(subscriber) ? _store.GetSubscriberPosition(subscriber) : -1;
 }
Beispiel #5
0
        public int SubscribePhone(string deviceId, string channelURI, string nick, string device)
        {
            var subscriber = new Subscriber {ChannelURI = channelURI, DeviceId = deviceId, Device = device, Nick = nick};

            #region If in developer mode
            if (Debugger.IsAttached)
            {
                OutputWindow.Show(string.Format("Phone with DeviceId {0} has been subscribed on channel {1}", subscriber.DeviceId.ToString(), subscriber.ChannelURI));
            }
            #endregion

            subscriber.Created = DateTime.Now;

            int position = _store.IsSubscribed(subscriber) ? _store.GetSubscriberPosition(subscriber) : _store.AddSubscriber(subscriber);
            SendRawMessageToAllUsers(string.Format("{0} ({1}) registered as number {2}", subscriber.Nick, subscriber.Device, position));

            return position;
        }