Beispiel #1
0
 private void WaitForHost(PeerInformation peer)
 {
     if (peer != null)
     {
         try
         {
             WaitingForHostParameters parameters = new WaitingForHostParameters()
             {
                 ConnectionType = Connection.BrowseAndConnect,
                 Peer           = peer,
                 Socket         = null,
             };
             PeerFinder.TriggeredConnectionStateChanged -= TriggeredConnectionStateChanged;
             ReceivedInvitations.SelectionChanged       -= InvitationSelected;
             ReceivedInvitations.SelectedItem            = null;
             Frame.Navigate(typeof(WaitingForHost), parameters);
         }
         catch (Exception err)
         {
             acceptInvitation.FontSize   = Constants.FontSizeNormal;
             acceptInvitation.LineHeight = Constants.FontSizeNormal;
             AcceptInvitation           += err.ToString();
         }
     }
 }
Beispiel #2
0
        private async void WaitForHost(StreamSocket connectSocket)
        {
            if (connectSocket != null)
            {
                try
                {
                    PeerFinder.TriggeredConnectionStateChanged -= TriggeredConnectionStateChanged;
                    WaitingForHostParameters parameters = new WaitingForHostParameters()
                    {
                        Socket         = connectSocket,
                        ConnectionType = Connection.TapAndConnect,
                        Peer           = null,
                    };

                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        Frame.Navigate(typeof(WaitingForHost), parameters);
                    });
                }
                catch (Exception err)
                {
                    AcceptInvitation += err.ToString();
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.  The Parameter
        /// property is typically used to configure the page.</param>
        private async void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // Users wait (i.e. watch progress) on this page until the connection has succeeded/failed.
            backButton.Visibility = Visibility.Collapsed;
            if (navigationParameter != null)
            {
                WaitingForHostParameters parameters = (WaitingForHostParameters)navigationParameter;
                if (parameters.Peer != null)
                {
                    pageTitle.Text = "Connecting to " + parameters.Peer.DisplayName.ToString() + "...";
                    try
                    {
                        StreamSocket socket = await PeerFinder.ConnectAsync(parameters.Peer);

                        pageTitle.Text = "Connected! Waiting for Host...";
                        this.socket    = new SocketReaderWriter(socket, this);
                        ConnectedPeer tempPeer = new ConnectedPeer(parameters.Peer.DisplayName);
                        connectedPeers[tempPeer] = this.socket;

                        PeerFinder.Stop();
                        StartReading();
                    }
                    catch (Exception)
                    {
                        pageTitle.Text = "Cannot connect to " + parameters.Peer.DisplayName;
                        PeerFinder.Stop();
                    }
                    progressBar.Visibility = Visibility.Collapsed;
                    backButton.Visibility  = Visibility.Visible;
                }
                else if (parameters.Socket != null)
                {
                    try
                    {
                        this.socket    = new SocketReaderWriter(parameters.Socket, this);
                        pageTitle.Text = "Waiting for Host...";
                        socket.WriteMessage(string.Format("{0} {1}", Constants.OpCodeSendDisplayName, PeerFinder.DisplayName));

                        PeerFinder.Stop();
                        StartReading();
                    }
                    catch (Exception)
                    {
                        pageTitle.Text = "Cannot connect";
                        PeerFinder.Stop();
                    }
                    backButton.Visibility  = Visibility.Visible;
                    progressBar.Visibility = Visibility.Collapsed;
                }
            }
        }
Beispiel #4
0
 private void WaitForHost(PeerInformation peer)
 {
     if (peer != null)
     {
         try
         {
             WaitingForHostParameters parameters = new WaitingForHostParameters()
             {
                 ConnectionType = Connection.BrowseAndConnect,
                 Peer = peer,
                 Socket = null,
             };
             PeerFinder.TriggeredConnectionStateChanged -= TriggeredConnectionStateChanged;
             ReceivedInvitations.SelectionChanged -= InvitationSelected;
             ReceivedInvitations.SelectedItem = null;
             Frame.Navigate(typeof(WaitingForHost), parameters);                 
         }
         catch (Exception err)
         {
             acceptInvitation.FontSize = Constants.FontSizeNormal;
             acceptInvitation.LineHeight = Constants.FontSizeNormal;
             AcceptInvitation += err.ToString();
         }
     }
 }
Beispiel #5
0
        private async void WaitForHost(StreamSocket connectSocket)
        {
            if (connectSocket != null)
            {
                try
                {
                    PeerFinder.TriggeredConnectionStateChanged -= TriggeredConnectionStateChanged;
                    WaitingForHostParameters parameters = new WaitingForHostParameters()
                    {
                        Socket = connectSocket,
                        ConnectionType = Connection.TapAndConnect,
                        Peer = null,
                    };

                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        Frame.Navigate(typeof(WaitingForHost), parameters);
                    });

                }
                catch (Exception err)
                {
                    AcceptInvitation += err.ToString();
                }
            }
        }