Silverlight

Apr 5, 2011 at 12:38 AM

Could you publish an example of consuming a super web socket in a silverlight client ?

Coordinator
Apr 5, 2011 at 3:12 AM

There is already a web socket client implementation:

http://superwebsocket.codeplex.com/SourceControl/changeset/view/63796#1387547

 

You can use it following the test case:

http://superwebsocket.codeplex.com/SourceControl/changeset/view/63796#1384207

 

There is another issue you should take care is policy server.

Silverlight socket client require a policy server in a specific port.

The policy server will be built in SuperSocket/SuperWebSocket, but I am not sure the time.

Apr 13, 2011 at 10:46 AM

Could you specify why silverlight client would need a Network policy server?

I am also trying to make a silverlight client which is able to connect to superwebsocket. So far I was using javascript to connect to websocket server and pass obejcts to silverlight client. This somehow worked but I would really like to be able to bypass javascript en the end.

Coordinator
Apr 13, 2011 at 11:07 AM
Edited Apr 13, 2011 at 11:08 AM

SuperSocket already has a built-in Silverlight policy server, you can make it work together with SuperWebSocket because they both base on SuperSocket.

What you need to do:

1) Get the latest code of SuperSocket from this page and compile it:

http://supersocket.codeplex.com/SourceControl/list/changesets

2) Build SuperWebSocket against latest SuperSocket(replace the SuperSocket assemblies in Reference folder of SuperWebSocket with the SuperSocket's output in previous step).

3) Add policy server's definition into your WebSocket server's configuration file.

Policy Server's configuration sample:

http://supersocket.codeplex.com/SourceControl/changeset/view/65451#1403636

You only require the configurations about Silverlight policy server, flash policy server's configuration is not requrired.

4) Reference the SuperSocket.Facility.dll in your WebSocket hosting project. Because The policy server's code is included in that assembly.

The file SuperSocket.Facility.dll is the output of SuperSocket's project "SuperSocket.Facilit".

5) Update the policy file according your requirement.

Finally, the policy server will run together with SuperWebSocket.

 

It seems I should update SuperWebSocket for latest SuperSocket. But SuperSocket 1.4 stable will be released before May, I probably update them together!

Coordinator
Apr 13, 2011 at 1:37 PM

You needn't build latest SuperSocket by yourself now.

I have updated SuperSocket references for SuperWebSocket, and the assembly file SuperSocket.Facility.dll already in reference folder.

You only need to do steps 3, 4, 5 of previous post to gain built-in policy server.

 

Apr 13, 2011 at 2:03 PM

Thank you very much for the guide and for updating the assemblies in SuperWebsocket, I'll definately try it as soon as possible!

I promise that I'll send you a link with finished project in the distant future if I manage to make this work. Also thanx for your rapid reply!

Coordinator
Apr 13, 2011 at 2:06 PM

Oh, great!

I am looking forward your project which is using SuperWebSocket/SuperSocket!

Apr 13, 2011 at 6:13 PM

Actually, making the Silverlight example work is slightly more complicated than this, because the WebSocket client cannot be compiled in Silverlight. The reason is that Silverlight's Socket implementation only contains *Async methods and lacks NetworkStream, MD5 and NamedValueCollection implementations.

Nevertheless, I got MD5 implementation from http://archive.msdn.microsoft.com/SilverlightMD5 and replaced the NamedValueCollection by a Dictionary<string, string> and managed to get the code running in Silverlight using the Async methods only. If you are interested I can do some testing of the code (and tweak it some, because the code is really messy right now), send it to you and you can integrate it to your project.

Apr 13, 2011 at 10:03 PM

Sorry, I am picking up this thread late in the game.

Does your above message mean that there is no working SL demo? What other options are there for IE8 clients?

If you have a working SL4 demo, I am very interetsed in taking a look at it.

Thanks,

Rick

Apr 13, 2011 at 10:17 PM

davecz> I knew about *Async methods but the rest of the missing implementantions is just bad news :-/ 

No really thank you for summing this up. I knew that using Silverlight will be a big challenge-especially considering that I started programing in C# like two months ago. I had a basics of Java, so object oriented programming was not a new concept, but the wast majority special features of C#, WPF and Silverlight took me by surprise.  I would be very much interested in seeing your sample code of the Silverlight client. Like our trainee in our university C# course says:"The best way to learn is to look at another's code." That's also the reason I am doing the Silverlight client-because I want to make a Silverlight web phorum as a school assignement. So please, even if it is buggy or messy, anything would help me. There really ain't no other resources for this. I did ENOUGH of google searches to say that websocket client was never done in Silverlight or at least wasn't published anywhere. 

Apr 13, 2011 at 11:08 PM
Edited Apr 16, 2011 at 3:52 PM

I made a working SL4 demo today - a simple chat app. There might be some hidden bug. But if I run the server on a localhost and allow SL our-of-browser + elevated trust so that I don't have to worry about that stupid access policy, it works.

EDIT: took down the demo as it's no longer relevant (and there were bug anyway).

Apr 13, 2011 at 11:21 PM

I should have know that it is you :D OMG ok, thanx.

Apr 14, 2011 at 12:58 AM

As for Silverlight WebSocket Server - look at http://html5labs.interoperabilitybridges.com/html5labs/prototypes/websockets/websockets/info/ (yay for MIX2011). There is also a Silverlight WebSocket implementation (tho the source code is not available) and I am pretty sure it's better than what I did :) 

Tho if you use this, you have to use "their" server as well.

Coordinator
Apr 14, 2011 at 2:31 AM

The client implementation in SuperWebSocket is very simple, and it is use async socket but not fully (The Connect behavior still use synchronous socket).

And the NameValueCollection problem can be resolved easily.

I'll update the code on these days, you also can use client in html5 labs.

 

Thanks,

Kerry Jiang

Coordinator
Apr 15, 2011 at 5:48 AM

Now there is a Silverlight 4 compatible WebSocket client provided by SuperWebSocket.

But I haven't test it yet because I haven't get a way to create NUnit test code for Silverlight assembly.