Sim*_*mon 2 wcf client duplex-channel
我有以下问题.我正在写聊天软件.客户端/服务器机制基于WCF的DualHttpBinding.这意味着如果用户发送消息,则服务器会通知发送消息的房间中的所有客户端.
我想确保,如果客户端的应用程序崩溃(无论如何),客户端对象将从房间列表中删除.
在调用回调操作之前是否有可能检查回调通道的状态?问题是,如果我在不再连接的客户端上调用操作(由于意外崩溃),该服务将挂起.
public YagzResult SendMessage(Message message)
{
foreach (ChatNodeAddress chatNodeAddress in message.Destination)
{
ChatNode chatNode = chatProvider.FindChatNode(chatNodeAddress);
if (chatNode != null)
{
User currentUser = CurrentUser;
foreach (User user in chatNode)
{
//Don't notify the current client. Deadlock!
if (!user.Equals(currentUser))
{
//Get the callback channel here
IYagzClient client = GetClientByUser(user);
if (client != null)
{
//--> If the client here called is not any more available,
//the service will hang <---
client.OnChatMessageReceived(message);
}
}
}
}
else
{
return YagzResult.ChatNodeNotFound;
}
}
return YagzResult.Ok;
}
Run Code Online (Sandbox Code Playgroud)
如何检查客户端是否仍在收听?顺便说一句,客户端调用的操作都声明为OneWay,ConcurrencyMode设置为"Multiple".
谢谢你们!
映入眼帘,
西蒙
| 归档时间: |
|
| 查看次数: |
11451 次 |
| 最近记录: |