Silverlight 3 Chat application with WCF Duplex Binding

How does the application work?
The ChatHost accepts connections from all Silverlight clients. Silverlight calls a 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 included 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

转载于:https://www.cnblogs.com/GT_Andy/archive/2009/07/24/1922047.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值