gpt4 book ai didi

azure - 向 Azure Functions 中 SignalR 服务中的一组用户发送消息

转载 作者:行者123 更新时间:2023-12-04 20:28:13 25 4
gpt4 key购买 nike

查看docs对于 SignalR 绑定(bind)向指定用户发送消息,您可以在消息中包含 UserId 属性 -

[FunctionName("SendMessage")]
public static Task SendMessage(
[HttpTrigger(AuthorizationLevel.Anonymous, "post")]object message,
[SignalR(HubName = "chat")]IAsyncCollector<SignalRMessage> signalRMessages)
{
return signalRMessages.AddAsync(
new SignalRMessage
{
// the message will only be sent to these user IDs
UserId = "userId1",
Target = "newMessage",
Arguments = new [] { message }
});
}

此示例直接取自文档,但注释暗示您向多个用户 ID 发送消息,即使该属性是字符串而不是数组。

您将如何指定多个用户? (例如,如果他们一起在私有(private)聊天 channel 中)或者评论的措辞是否存在错误,您需要向每个用户发送一条消息?

对于其他版本的 SignalR,我会将它们放在一个组中,但函数不存在对此的绑定(bind)。

最佳答案

latest release中引入了集团运营.

现在您可以:

  • 使用 GroupName 向群组发送消息在SignalRMessage
  • 使用 IAsyncCollector<SignalRGroupAction> 添加/删除组中的用户输出

关于azure - 向 Azure Functions 中 SignalR 服务中的一组用户发送消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53156005/

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