Silverlight 3 chat application with WCF duplex binding

Source: Internet
Author: User

How does the application work?
The chathost accepts connections from all Silverlight clients. Silverlight calla login method on the chathost and the chathost holds a list Of all connected clients.

When a Silverlight clients sends a message to the chatbox, The chathost will broadcast this message to all connected clients.

If it fails to deliver the message to the client, the client probably closed it's browser and is removed from the connected clients list.

Live example:

Tip: If there are no people to chat with, invite a friend or open 2 browser windows.

Client Access Policy
The chathost server is running on a different port number than the Silverlight webpage's (port 80 ). because port 80 is used by IIS, The chathost can't host the WCF services on the same port number.
But Silverlight is not automatically allowed to access services on other servers/ports. So a client access policy file (clientaccesspolicy. XML) must be provided by the target server.
The chathost can provide this file to Silverlight through the crossdomainservice. CS which is stored in the chathost project.

How to get this working on your server?

  1. Download the source code
  2. Modify the app. config of the chathost and change the servicebase setting. Change the server name and port number to the name of your server and a port number you like.
  3. Modify the Silverlight project and specify the server name and port of the WCF endpoint (which you modified at Step 2 ).
  4. Compile the projects
  5. Run the server
  6. Run Silverlight Project
Download the full source code of the project here.

Silverlight sockets
Are you looking for a socket based Silverlight chat application?
Http://www.michielpost.nl/PostDetail_7.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.