1
블루투스를 통해 두 장치를 연결하는 Windows Phone 8 프로젝트가 있습니다. 내 전화기와 다른 장치를 연결하려고하면 다른 장치에서 연결을 기다리고 있습니다. 그러나 장치가 연결 요청을 보내면 PeerFinder_ConnectionRequested
이벤트가 발생하지 않습니다. 내 코드 :청취 블루투스 장치 연결 Windows phone
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;
}
내가 잘못하고있는 것을 누구든지 볼 수 있습니까?