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?
- Download the source code
- 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.
- Modify the Silverlight project and specify the server name and port of the WCF endpoint (which you modified at step 2).
- Compile the projects
- Run the server
- Run Silverlight project
Are you looking for a socket based Silverlight chat application?