This sample creates a WCF chat service and builds a Silverlight client for it; both service and client are then hosted in the Azure fabric. The sevice is built using the PollingDuplexBindingElement which allows the service to push information to the client, as described in
this set of topics.
Note that an interesting scenario to explore here would be a distributed chat server where we add more chat service instances as client demand grows. Unforunatly this is currently not possible, as the chat server maintains an in-memory table storing all the client sessions. Until the implementation of PollingDuplexBindingElement allows the session table to be stored in external storage, only one instance of the chat server can be run. For more information see
Hosting Silverilght Clients > Multiple instances of duplex services using PollingDuplexHttpBinding on the
KnownIssues page.
Here is a quick walkthrough of the steps taken to build this solution:
- Create new Web Cloud Service project called Calculator
- Port the contents of the sample posted here
Demo Client |
Demo Service To try out the chat scenario, open up multiple instances of the Silverlight client. Note that each instance needs to be opened in a
separate browser process (not tab), or in a different browser. Some browsers have a 2 connection limit, which will be exhausted if more than one client instance is run within the same browser process. This is not an issue in a production environment since customers would run only one chat window at a time.
Here is a screenshot of two Silverlight clients chatting: