http://forums.asp.net/p/
http://stackoverflow.com/
http://www.codeproject.com/
http://www.codeguru.com/
http://support.microsoft.com/
But unfortunately the only promising one's required a C# Visual Studio template called "ASP.NET Web Service". I tried searching all over for how to get this template. I started with Visual Studio 2012 and decided I might need VS Web 2012 to get this special template. After installing it I had access to several C#/ASP Templates however none of them were the "Web Service" template the tutorials kept mentioning. I then tried VS 2010 and Web 2010 with no luck. I did some searching on the "ASP.NET Web Service" template and found that it required .NET Framework 3.5 and that I had 4 and 4.5. I installed 3.5 but even then VS would not let me target the 3.5 framework when selecting from C# Web templates and I ultimately gave up on using Microsoft's templates.
Dr. Remy then recommended this C# server after some brief googling. I did some googling of my own and found a simpler one here. I threw it into my VS 2012 project and it worked like a charm, at least the sample did. Changing the server to output one of the skeleton joints instead of the sample string was very painful.
First, the web server class constructor required a static function to be used as the GET response handler. Making such a function static however cut of its access to the MainWindow class in my application which had the Kinect data. Then I added a method to the web server to allow setting a new response method and since it wasn't a constructor, the method didn't have to be static. Then I was able to declare a function in my main class (with the Kinect) that would return the Kinect data as a string which I hoped the web server would then respond with. However this failed due to a "cross-thread communication" exception. Then I created a static "DataPasser" class with global scope. In MainWindow I store the Kinect data in DataPasser and in the web sever response method I simply get the property from DataPasser. This worked however I didn't realize it at first since I had put the code that updates the DataPasser values in a function that is only called once the Kinect has detected a skeleton. Since I was running several trials of the program, I did not stand up and let the Kinect recognize my skeleton and thus no data (an empty web page) was returned to my requests.
After getting the data sorted out, I had to take the web server one step further and test it on another machine (up to this point I had done all testing on localhost). I found that from my laptop, which was on the same network as the desktop I was doing development on, I could not access the server. I did some googling and realized that the httplistener prefix "http://loclahost:8080/" only targets localhost and that "http://*:8080/index/" needed to be used to accept requests from any source. Upon trying this new prefix however VS was unable to run the program due to a failed call to the httplistener constructor. I did some more googling and found out this might be permissions related. Sure enough, restarting VS with admin rights fixed the issue and I was able to use the new prefix. However I was still unable to see the web server from my other laptop! Bringing down the firewall fixed this issue though so I added an exception to my firewall for the web server port and now it can be accessed from another machine on the network.
The next step in my development will now be to implement the HTML interface that will read the data and pan a sound based on the given position.
No comments:
Post a Comment