Skip to content

Commit 658eec1

Browse files
committed
Move the public connection setup to window onload, fixes #34
1 parent 6d3133d commit 658eec1

12 files changed

Lines changed: 23 additions & 16 deletions

Kinect2JSON/Kinect2JSON.v12.suo

1.5 KB
Binary file not shown.

Kinect2JSON/Kinect2JSON/MainWindow.xaml.cs

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,15 @@ public MainWindow()
155155
SetupColorDisplay();
156156
SetupBodyJointsDisplay();
157157
InitializeLocalConnection();
158-
InitializePublicConnection();
159158

160159
InitializeComponent();
161160
}
162-
163-
//starting up the websocket server
164-
//we use 0.0.0.0:8181 because reasons. (I followed other people's ideas, and it works fine)
161+
/*
162+
* starting up the local websocket server
163+
* we use 127.0.0.1:8181 because that's the local computer ip.
164+
*/
165165
public static void InitializeLocalConnection()
166166
{
167-
//System.Threading.Thread.Sleep(5000);
168167
//local server
169168
var server = new WebSocketServer("ws://127.0.0.1:8181");
170169

@@ -189,11 +188,19 @@ public static void InitializeLocalConnection()
189188
});
190189
}
191190

191+
/*
192+
* starting up the public websocket server
193+
* we use 127.0.0.1:8181 because that's the local computer ip.
194+
* this is run after the window loads so as to not slow down the window loading
195+
* */
192196
public static void InitializePublicConnection()
193197
{
194198

195199
//server on the public ip
196-
var server1 = new WebSocketServer("ws://"+GetPublicIP()+":8181");
200+
var server1 = new WebSocketServer("ws://" + GetPublicIP() + ":8181");
201+
202+
//When a socket opens, add it to the client list, when it closes, remove it,
203+
//and when the socket recieves a message, transmit the message.
197204
server1.Start(socket =>
198205
{
199206
socket.OnOpen = () =>
@@ -649,7 +656,6 @@ private void SetupBodyJointsDisplay()
649656
public static string GetPublicIP()
650657
{
651658
string url = "http://checkip.dyndns.org";
652-
//System.Threading.Thread.Sleep(5000);
653659
System.Net.WebRequest req = System.Net.WebRequest.Create(url);
654660
System.Net.WebResponse resp = req.GetResponse();
655661
System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
@@ -662,7 +668,9 @@ public static string GetPublicIP()
662668
}
663669

664670
/// <summary>
665-
/// Execute start up tasks
671+
/// Execute start up tasks.
672+
/// InitializePublicConnection is here instead of in Main Window,
673+
/// because it is sometimes slow.
666674
/// </summary>
667675
/// <param name="sender">object sending the event</param>
668676
/// <param name="e">event arguments</param>
@@ -672,8 +680,7 @@ private void MainWindow_Loaded(object sender, RoutedEventArgs e)
672680
{
673681
this.multiSourceFrameReader.MultiSourceFrameArrived += this.Reader_MultiSourceFrameArrived;
674682
}
675-
676-
683+
InitializePublicConnection();
677684
}
678685

679686
/// <summary>

Kinect2JSON/Kinect2JSON/bin/Debug/Kinect2JSON.application

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
1515
</dsig:Transforms>
1616
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
17-
<dsig:DigestValue>6OBWke/3qc3YrQNCmJ1zxUv/SDXF25atnOAZNCeLWhg=</dsig:DigestValue>
17+
<dsig:DigestValue>3ULdQDYE42vAbmFvSpUc3Zb23p2pLu+r72zCcvVedXs=</dsig:DigestValue>
1818
</hash>
1919
</dependentAssembly>
2020
</dependency>
0 Bytes
Binary file not shown.

Kinect2JSON/Kinect2JSON/bin/Debug/Kinect2JSON.exe.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
6262
</dsig:Transforms>
6363
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
64-
<dsig:DigestValue>hAigRapW1JxbRQvqZWGe9+n98/gjykjUcYOmU6XbiwA=</dsig:DigestValue>
64+
<dsig:DigestValue>hSnyUIEI9WrHhlqlVXIr7JxgiE0B1IKOKzaw3cIOhMo=</dsig:DigestValue>
6565
</hash>
6666
</dependentAssembly>
6767
</dependency>
0 Bytes
Binary file not shown.

Kinect2JSON/Kinect2JSON/bin/Debug/Kinect2JSON.vshost.application

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
1515
</dsig:Transforms>
1616
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
17-
<dsig:DigestValue>AK748VXAnDg1mf3bEjAnQ5ENKnqftID2gUVUuevHLNM=</dsig:DigestValue>
17+
<dsig:DigestValue>3ULdQDYE42vAbmFvSpUc3Zb23p2pLu+r72zCcvVedXs=</dsig:DigestValue>
1818
</hash>
1919
</dependentAssembly>
2020
</dependency>

Kinect2JSON/Kinect2JSON/bin/Debug/Kinect2JSON.vshost.exe.manifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
6262
</dsig:Transforms>
6363
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
64-
<dsig:DigestValue>DO69nezRXIQnNurw9ymcww62gxp4QqnEQbBwExdwGEg=</dsig:DigestValue>
64+
<dsig:DigestValue>hSnyUIEI9WrHhlqlVXIr7JxgiE0B1IKOKzaw3cIOhMo=</dsig:DigestValue>
6565
</hash>
6666
</dependentAssembly>
6767
</dependency>

Kinect2JSON/Kinect2JSON/obj/Debug/Kinect2JSON.application

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
1515
</dsig:Transforms>
1616
<dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha256" />
17-
<dsig:DigestValue>6OBWke/3qc3YrQNCmJ1zxUv/SDXF25atnOAZNCeLWhg=</dsig:DigestValue>
17+
<dsig:DigestValue>3ULdQDYE42vAbmFvSpUc3Zb23p2pLu+r72zCcvVedXs=</dsig:DigestValue>
1818
</hash>
1919
</dependentAssembly>
2020
</dependency>
0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)