/// <summary> /// Connection state changed /// </summary> /// <param name="sender"></param> /// <param name="args"></param> async void PeerFinder_TriggeredConnectionStateChanged(object sender, TriggeredConnectionStateChangedEventArgs args) { try { if (args.State == TriggeredConnectState.PeerFound) { //Display a status message Deployment.Current.Dispatcher.BeginInvoke(() => { txtStatus.Text = "Peer Found!"; }); } else if (args.State == TriggeredConnectState.Completed) { //Display a status message Deployment.Current.Dispatcher.BeginInvoke(() => { txtStatus.Text = "Receiving File..."; }); //Set the socket streamSocket = args.Socket; //Start receiving the song conn = new NFCConnection(Deployment.Current.Dispatcher, progressReceive, txtFile); await conn.ReceiveSongFromSocket(streamSocket); //Navigate to the home page Deployment.Current.Dispatcher.BeginInvoke(() => { NavigationService.Navigate(new Uri("/BrowsePage.xaml", UriKind.Relative)); }); } } catch (Exception ex) { string error = ex.Message; MessageBox.Show(ex.Message); } }
/// <summary> /// Connection state changed /// </summary> /// <param name="sender"></param> /// <param name="args"></param> async void PeerFinder_TriggeredConnectionStateChanged(object sender, TriggeredConnectionStateChangedEventArgs args) { if (args.State == TriggeredConnectState.PeerFound) { Deployment.Current.Dispatcher.BeginInvoke(() => { txtStatus.Text = "Peer Found"; }); } else if (args.State == TriggeredConnectState.Completed) { Deployment.Current.Dispatcher.BeginInvoke(() => { txtStatus.Text = "Transferring"; }); //Stop broadcasting the connection PeerFinder.Stop(); started = false; //Set the socket streamSocket = args.Socket; //Send the selected ringtone conn = new NFCConnection(Deployment.Current.Dispatcher, progressSend, txtStatus); await conn.SendSongOverSocket(streamSocket, Session.SharedFile.Name, Session.SharedFile.Name, Session.SharedFile.Size.ToString()); Deployment.Current.Dispatcher.BeginInvoke(() => { NavigationService.GoBack(); }); } }