Monday, April 23, 2012

Silverlight websockets and windows phone day 2

Unproductive weekend is over, now I have to get back to websockets on the phone.
Downloaded the source for websockets4 from http://websocket4net.codeplex.com/ but the example code still gives me errors after adding various things to the project.

Tried to use the nuGet plugin from visual studio and I get an error

PM> Install-Package WebSocket4Net
Attempting to resolve dependency 'Json.Net (≥ 4.0.5.14411)'.
Install-Package : Unable to resolve dependency 'Json.Net (≥ 4.0.5.14411)'.
At line:1 char:16
+ Install-Package <<<<  WebSocket4Net
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageComman 
   d


PM> 
So that failed. And there's no obvious way to get help, damnit. First experience with nuGet sucks. first experience with websockets4 sucks. So i try to get Json from somewhere else, and try to use that, and nothing new happens with the dependencies other than I have more references added in the directory.

So im going to try http://html5labs.interoperabilitybridges.com/prototypes/websockets/websockets/download
the sort of official implementation of websockets. from the Microsoft site I find that I need to include "using System.Json" which I don't have. So I also need to go get that. So after more reading I find that Json is not supported by Windows Phone, so another dead end.

None of those projects worked with sockets as the functions that I needed like TcpClient dont exist for Windows Phone. So WebSocket4Net doesn't do much without the TcpClient, or things like Listen... looking at that again to see if there's something I missed...

update 6pm
further investigation leads me to believe that websocket4net might still have some solutions, it's just undocumented and opaque. WebSocketSamples.zip from their site should shed some light on how the functions are used. I hope.

So, im doing something liket this...
ws = new WebSocket(("ws://" + hostName + ":" + portNumber));

ws.Opened += new EventHandler(ws_Opened);
ws.Open();
Debug.WriteLine("state?" + ws.State.ToString());
So the Output for that ends up like
state?Connecting
So im guessing that there's something missing on the server side.
But it is doing something... I think im getting closer.

No comments:

Post a Comment

rxokita's shared items