Windows Phone 7: Callbacks and Duplex WCF

As Windows Phone 7 (WP7) does not seem to support application-level sockets at the moment I was looking into using WCF to implement a simple client-server application. Further, my application required messages to be sent in both directions. Think of a chat application for example where messages need to be sent  from client to server as well as from server to client.

However, WCF on WP7 supports BasicHttpBinding only (i.e., no duplex operations using WSDualHttpBinding for example). Push notifications seem to provide an alternative (especially raw notifications). They have to go through a web service, though. I did not do any testing but I would imagine that this introduces substantial lags.

WP7 Communication (General Callback)In the end, I decided for a polling strategy where the phone (client) continuously asks the server if a callback was requested (by the server). If so, the client invokes a method on the server to retrieve callback parameters. The actual method is then executed on the client and its result returned in a second call to the server.

The callback type is identified by a string (e.g., “Add”). An actual callback execution is identified by a GUID. For the sake of simplicity, above diagram does not reflect the asynchronous WCF communication used for communications between client and server.

One thought on “Windows Phone 7: Callbacks and Duplex WCF

Comments are closed.