MSDN Archive Home
Help and FAQs
WCF Event Publishing
All Resource Updates
Votes in Release
Running the Sample
Start the service first and it should show you a message saying that the service is running.
Start as many instances of the client as you want and connect to the service. (The UI is intuitive enough i guess !)
Note: The sample is configured to run properly when both the client and the service is hosted on the same machine. Scroll to the end of the article for instructions for setting up the service and client on different machines.
The Service - Console Application
with three methods.
- SendMessage. - Broadcasts the message sent by the client to all connected clients including itself.(Hence the 'Chat room' effect.)
- Join - Used by the clients to subscribe to the 'Broadcast' event. (Join the chat room)
- Leave - Used by the clients to unsubscribe from the 'Broadcast' event.(Leave the chat room)
with one method.
RecieveMessage - Implemented by the client and invoked by the service during broadcast.
( A dual tcp might perform even better !)
Note: All the methods in the service contract are marked as 'One Way' due to this.
event is defined and is declared as static so that it is shared by all the clients.
The Client - Windows Forms Application
As stated earlier, the client application must be 'Stateful' and hence a windows aplication has been used. The client class implements the callback interface of the service. It then merely uses the appropriate method of the service based on the user actions.
(You might find more lines of code that does not relate to any of what has been mentioned here and all that is related to UI validations, exception handling and proper port identification for the client)
Hosting the Service and Client on different machines
A few changes have to be made in the configuration file('app.config' in the sample) of the
application before it can be run from a different machine. To be more precise, TWO changes have to be made.
1. In bindings >> wsDualHttpbinding >> binding - look for an attribute named 'clientBaseAddress'. Replace 'localhost' by the name/ip of the
2. In client >> endpoint - look for an attribute named 'address'. Replace 'localhost' by the name/ip of the server.
And you're done...!!!
WCF Service and Client
source code, 241K, uploaded
Mar 13 2008
- 2469 downloads
To download the file you must agree to the following license.
Microsoft Public License (Ms-PL) This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. 1. Definitions The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law. A "contribution" is the original software, or any additions or changes to the software. A "contributor" is any person that distributes its contribution under this license. "Licensed patents" are a contributor's patent claims that read directly on its contribution. 2. Grant of Rights (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. 3. Conditions and Limitations (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. (D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement.
There are no planned releases for this resource.
Mar 14 2008
Mar 13 2008
Manage Your Profile
MSDN Flash Newsletter
© 2008 Microsoft Corporation. All rights reserved.