Beispiel #1
0
        public void EndConnection()
        {
            //make sure we're not calling this multiple times
            if (this.CurrentState != SystemState.LoggedOut)
            {
                this.CurrentState = SystemState.LoggedOut;

                //reset UI after changing SystemState
                P2pWorker.ReportProgress(0, ThreadMessage.Create(UiMessage.ToggleUi, string.Empty));

                //close and set classes to null
                if (p2p != null)
                {
                    p2p.Close();
                    p2p = null;
                }

                if (videoHttpListener != null)
                {
                    videoHttpListener.Stop();
                    videoHttpListener.Quit();
                    videoHttpListener = null;
                }

                if (P2pWorker != null)
                {
                    P2pWorker.CancelAsync();
                }
            }
        }
Beispiel #2
0
        private void P2pWorkerAsync(object sender, DoWorkEventArgs doWorkArgs)
        {
            //Send back a text that we're logging in
            P2pWorker.ReportProgress(0, ThreadMessage.Create(UiMessage.ToggleUi, string.Empty));

            //Create new p2p
            p2p = new P2PLib();

            //Connect to the PeerChannel
            bool start = p2p.PeerChannelWrapperStart(userName, networkName, password);

            //check for connection error
            if (!start)
            {
                EndConnection();
            }

            SubscribeToPeerChannelEvents();

            //PeerChannel connection may take a while so cycle the ProgressBar
            CycleProgressBarUntilConnected();

            SitAndWait();
        }