gpt4 book ai didi

WCF 双工 channel : Check if callback channel is still available

转载 作者:行者123 更新时间:2023-12-02 06:25:14 24 4
gpt4 key购买 nike

我有以下问题。我在写聊天软件。客户端/服务器机制基于 WCF 的 DualHttpBinding。这意味着,如果用户发送消息,服务器会通知发送消息的房间中的所有客户端。

我想确保,如果客户的应用程序崩溃(不管是什么原因),客户对象将从房间列表中删除。

是否有可能在调用回调操作之前检查回调 channel 的状态?问题是,如果我在不再连接的客户端上调用操作(由于意外崩溃),服务将挂起。

 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;
}

我如何检查客户端是否仍在收听?顺便说一句,在客户端调用的操作都声明为 OneWay 并且 ConcurrencyMode 设置为“Multiple”。

谢谢大家!

问候,

西蒙

最佳答案

您可以将回调合约转换到ICommunicationObject然后检查 channel 状态。

关于WCF 双工 channel : Check if callback channel is still available,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1981113/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com