Chapter 14: Using a Callback Contract to Publish and Subscribe to Events


image from book Download CD Content

Overview

After completing this chapter, you will be able to:

  • Define a callback contract enabling a WCF service to call back into a client application.

  • Create a client application that implements a callback contract.

  • Use a callback contract to build a simple mechanism for alerting client applications about significant events.

The examples and exercises that you have seen so far in this book have concentrated on the client/server model of processing. In this model, a server provides a service that waits passively for a request from a client application, handles that request, and then optionally sends a response back to the client application. The client application is the active participant, making requests and effectively determining when the service should perform its work. While this is the most common model, WCF supports other processing schemes, such as peer-to-peer networking and client callbacks.

In the peer-to-peer scenario, there are no passive services. All applications are autonomous clients that can communicate with each other as equals (or peers). There is no client/server relationship, and applications should be prepared to handle messages sent to them at any time.

More Info 

Peer-to-peer technologies are an integral part of Windows Vista but require you to manually install Peer Networking services if you are using Windows XP. You must also configure the peer-to-peer infrastructure. WCF provides the PeerChannel for communicating between peers and defines the NetPeerTcpBinding binding to enable you to configure the communication parameters. Detailed discussion of using WCF to build peer-to-peer applications is outside the scope of this book, but the Windows SDK documentation provides information and examples in the Peer to Peer Networking section, under Windows Communication Foundation. You can find further information about configuring and building peer-to-peer applications and services online in the Windows Peer-to-Peer Networking site at http://www.microsoft.com/technet/itsolutions/network/p2p/default.mspx. Additionally, you can find a good overview and introduction to building peer-to-peer applications on the MSDN Web site at http://msdn.microsoft.com/msdnmag/issues/06/10/PeerToPeer.

Using client callbacks, a service can invoke a method in a client application, in essence inverting the client/server relationship between the client application and the service. In this chapter, you will look at how to define a client callback and how to use it to implement a simple eventing mechanism for alerting interested client applications about a change of state in the service.




Microsoft Windows Communication Foundation Step by Step
Microsoft Windows Communication Foundation Step by Step (Step By Step Developer Series)
ISBN: 0735623368
EAN: 2147483647
Year: 2007
Pages: 105
Authors: John Sharp

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net