@@ -148,6 +148,8 @@ public string KinectStatusText
148148 }
149149 }
150150
151+ //Boolean stating whether the server has started
152+ public bool publicStarted = false ;
151153 //The code that updates the status text based on whether the public connection has started.
152154 //Changed in InitializePublicConnection
153155 private string publicConnectionStatusText = "hello!" ;
@@ -175,7 +177,7 @@ public MainWindow()
175177 SetupColorDisplay ( ) ;
176178 SetupBodyJointsDisplay ( ) ;
177179 InitializeLocalConnection ( ) ;
178- InitializePublicConnection ( ) ;
180+ // InitializePublicConnection();
179181
180182 InitializeComponent ( ) ;
181183 }
@@ -216,7 +218,6 @@ public static void InitializeLocalConnection()
216218 * */
217219 public void InitializePublicConnection ( )
218220 {
219-
220221 //server on the public ip
221222 var server1 = new WebSocketServer ( "ws://" + GetPublicIP ( ) + ":8181" ) ;
222223
@@ -239,7 +240,6 @@ public void InitializePublicConnection()
239240
240241 } ;
241242 } ) ;
242-
243243 PublicConnectionStatusText = "Public Connection Started" ;
244244 }
245245
@@ -697,13 +697,13 @@ public static string GetPublicIP()
697697 /// </summary>
698698 /// <param name="sender">object sending the event</param>
699699 /// <param name="e">event arguments</param>
700- private void MainWindow_Loaded ( object sender , RoutedEventArgs e )
700+ private void MainWindow_Activated ( object sender , EventArgs e )
701701 {
702- if ( this . multiSourceFrameReader != null )
702+ if ( ! publicStarted )
703703 {
704- this . multiSourceFrameReader . MultiSourceFrameArrived += this . Reader_MultiSourceFrameArrived ;
704+ InitializePublicConnection ( ) ;
705+ publicStarted = true ;
705706 }
706- //InitializePublicConnection();
707707 }
708708
709709 /// <summary>
0 commit comments