Example #1
0
        public Peripheral GetOrAdd(CBCentral central)
        {
            if (!this.peripherals.ContainsKey(central.Identifier))
            {
                this.peripherals.Add(central.Identifier, new Peripheral(central));
            }

            return(this.peripherals[central.Identifier]);
        }
Example #2
0
        public Peripheral GetOrAdd(CBCentral central)
        {
            if (!this.peripherals.ContainsKey(central.UUID))
            {
                this.peripherals.Add(central.UUID, new Peripheral(central));
            }

            return(this.peripherals[central.UUID]);
        }
Example #3
0
        private void OnReceivedMessage(string message, CBCentral central)
        {
            lock (central)
            {
                var user = _userStorage.GetUser(central.Identifier);

                if (user != null)
                {
                    SaveMessageItem(new MessageItem(message, user, DateTime.Now));
                }
            }
        }
Example #4
0
 IDevice Remove(CBCentral central)
 {
     lock (this.subscribers)
     {
         if (this.subscribers.ContainsKey(central.Identifier))
         {
             var device = this.subscribers[central.Identifier];
             this.subscribers.Remove(central.Identifier);
             return(device);
         }
         return(null);
     }
 }
Example #5
0
        public Peripheral SetSubscription(CBCentral central, bool subscribe)
        {
            var peripheral = this.GetOrAdd(central);

            if (subscribe)
            {
                this.subscribed.Add(central.Identifier, peripheral);
            }
            else
            {
                this.subscribed.Remove(central.Identifier);
            }
            return(peripheral);
        }
Example #6
0
        IDevice GetOrAdd(CBCentral central)
        {
            lock (this.subscribers)
            {
                if (this.subscribers.ContainsKey(central.Identifier))
                {
                    return(this.subscribers[central.Identifier]);
                }

                var device = new Device(central);
                this.subscribers.Add(central.Identifier, device);
                return(device);
            }
        }
 public override void CharacteristicUnsubscribed(CBPeripheralManager peripheral, CBCentral central, CBCharacteristic characteristic)
 {
     SensusServiceHelper.Get().Logger.Log("Characteristic unsubscribed.", LoggingLevel.Normal, GetType());
 }
Example #8
0
 public Peripheral(CBCentral central)
 {
     this.Central = central;
     this.Uuid    = central.Identifier.ToString();
 }
Example #9
0
 public Device(CBCentral central)
 {
     this.Central = central;
     this.Uuid    = new Guid(central.Identifier.ToString());
 }