Silverdraw is realtime white board that can sync information between various participants, using Silverlight + WCF Polling Duplex. Presently this is a just a POC implementation. Users can draw together in the white board, and may chat each other. Here is a quick screen shot of the client running in two different browsers. These are the steps to start.
The application has two parts:
- Server - A WCF service with a polling duplex end point for clients to register, to publish information, and to receive notifications.
- Client - A Silverlight client that consumes the end point to register the user, to publish the user's drawing, and to receive and plot the drawing data from other users.
The server side web service interface (
IDuplexDrawService) has these important methods:
Register- A client may call this to register itself to a conversation.
Draw- A client may call this to request the server to pump the drawing information to other clients in the conversation
NotifyClients- From the
Drawmethod, we'll invoke
NotifyClientsto iterate the registered clients, to publish the data.
Also, as we are using Polling Duplex, we need a callback interface too - so that the server can 'call back' or notify the clients. (In Polling Duplex, you may need to note that what is happening is not actually a direct callback from server to client. The client should poll the server periodically over HTTP to fetch any possible information that the server is willing to pass to the client, to simulate a callback.) Anyway, our 'call back' service interface (
IDuplexDrawCallback) has a
Notify method, for the server to notify the rest of the clients when some client calls the
So, in short - a party may publish some information using '
Draw', and others can subscribe to the published information. This is a simple implementation of the Publisher/Subscriber pattern.
When you load the client the first time, you'll be asked for a username to join the session. From there, the logic goes something like:
- The client will try to connect to the service end point.
- If success, the client will register itself with the client, by calling the
Registermethod, and by passing the username.
- The client will hook up a few event handlers in the proxy. Mainly, the
NotifyCompletedwill be fired each time you receive a callback from the server.
- Inside the
Registermethod, the server will grab the client's session ID and callback channel from the current operation context, and add it to a list.
- Whenever a client submits information by calling '
Draw', the server will pump this information by iterating each registered client, and by calling their '
How To Start:
- Read this intro post in my blog, watch this video
- Take a live demo here – Silverdraw.com
- Read this codeproject article to help you understand the source in detail
- Get the source - Click downloads link in Codeplex to grab the source
Enjoy, happy coding!!