How does the application work?
The ChatHost accepts connections from all Silverlight clients. Silverlight calls a login method on the ChatHost and the ChatHost holds a list of all connected clients.

When a Silverlight clients sends a message to the chatbox, the ChatHost will broadcast this message to all connected clients.

If it fails to deliver the message to the client, the client probably closed it's browser and is removed from the connected clients list.

Live Example Currently Offline

Client Access Policy
The ChatHost server is running on a different port number than the Silverlight webpage's (port 80). Because port 80 is used by IIS, the ChatHost can't host the WCF services on the same port number.
But Silverlight is not automatically allowed to access services on other servers/ports. So a Client Access Policy file (clientaccesspolicy.xml) must be provided by the target server.
The ChatHost can provide this file to Silverlight through the CrossDomainService.cs which is included in the ChatHost project.

How to get this working on your server?

  1. Download the source code
  2. Modify the App.config of the ChatHost and change the ServiceBase setting. Change the server name and port number to the name of your server and a port number you like.
  3. Modify the Silverlight project and specify the server name and port of the WCF endpoint (which you modified at step 2).
  4. Compile the projects
  5. Run the server
  6. Run Silverlight project

Download the full source code of the project here.

Silverlight Sockets
Are you looking for a socket based Silverlight chat application?
http://www.michielpost.nl/PostDetail_7.aspx