【问题标题】:listening bluetooth device connecting windows phone监听蓝牙设备连接 windows 手机
【发布时间】:2013-10-29 21:07:31
【问题描述】:

我在 Windows Phone 8 中有一个项目,它通过蓝牙连接两个设备。当我尝试连接我的手机和其他设备时,我的手机正在侦听/等待来自其他设备的连接。但是当我的设备发送连接请求时,PeerFinder_ConnectionRequested 事件不会触发。我的代码:

public MainPage()
{
   InitializeComponent();
   Loaded += MainPage_Loaded;
}

void MainPage_Loaded(object sender, RoutedEventArgs e)
{
   PeerFinder.ConnectionRequested += PeerFinder_ConnectionRequested;
}

void PeerFinder_ConnectionRequested(object sender, ConnectionRequestedEventArgs args)
{
   if (ShouldConnect())
    {
       // Go ahead and connect
       ConnectToPeer(args.PeerInformation);
    }
}

async void ConnectToPeer(PeerInformation peer)
{
   StreamSocket socket = await PeerFinder.ConnectAsync(peer);
   MessageBox.Show ("Completed");
}

private bool ShouldConnect()
{
   // Determine whether to accept this connection request and return
   return true;
}

谁能看出我做错了什么?

【问题讨论】:

    标签: c# windows-phone-7 bluetooth windows-phone-8


    【解决方案1】:

    你开始寻找同伴了吗?

    PeerFinder.Start()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多