Ejemplo n.º 1
0
        public async Task<PeripheralHandler> CreateHandlerAsync(CBPeripheral peripheral)
        {
            var handler = new PeripheralHandler(peripheral);

            await handler.InitializeAsync();

            List.Add(handler);
            return handler;
        }
Ejemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _contactedUserHandler = BluetoothClient.Instance.ConnectionManager.GetPeripheralHandler(_contactedUser);

            View.BackgroundColor = UIColor.White;
            Root.TableView.SeparatorColor = UIColor.Clear;

            ReadMessages();
            _messageStorage.Subscribe(_contactedUser, OnReceivedMessage);
        }
        public async Task Connect(NSUuid peripheralUuid)
        {
            var peripheralHandler = _peripheralHandlerList.FirstOrDefault(p => p.Uuid.IsUuidEqual(peripheralUuid));
            if (peripheralHandler != null && peripheralHandler.IsConnected)
            {
                return;
            }

            using (var handler = new BluetoothConnectionHandler(_manager))
            {
                peripheralHandler = new PeripheralHandler(await handler.ConnectAsync(peripheralUuid));
                await peripheralHandler.InitializeAsync();

                peripheralHandler.InviteForDataExchange();
                _peripheralHandlerList.Add(peripheralHandler);

                OnConnectedUser(peripheralHandler);
            }
        }
 protected virtual void OnConnectedUser(PeripheralHandler peripheralhandler)
 {
     var handler = ConnectedUser;
     if (handler != null) handler(peripheralhandler);
 }