Example #1
0
 private void ConnectionRequested(object sender, ConnectionRequestedEventArgs args)
 {
     try {
         Dispatcher.BeginInvoke(() => {
             Bluetooth.ConnectToPeer(args.PeerInformation);
             rivalName  = args.PeerInformation.DisplayName;
             var result = MessageBox.Show(String.Format("Пользователь {0} предлагает вам игру. Принять приглашение?",
                                                        rivalName), "Приглашение", MessageBoxButton.OKCancel);
             if (result == MessageBoxResult.OK)
             {
                 Bluetooth.SendCommand(BluetoothCommands.AcceptInvite);
             }
             else
             {
                 Bluetooth.SendCommand(BluetoothCommands.DiscardInvite);
                 Bluetooth.Disconnect();
             }
         });
     }
     catch (Exception ex) {
         MessageBox.Show(ex.Message);
     }
 }