gpt4 book ai didi

azure-functions - 在 .NET 5.0 中向 signalR 组添加/删除用户

转载 作者:行者123 更新时间:2023-12-04 17:19:55 24 4
gpt4 key购买 nike

以下代码在.netcoreapp3.1中一直有效,但将Http-triggered函数迁移到.NET 5.0后,它停止了:

public static class AddToGroup
{
[Function("addtogroup")]
public static Task Run(
[HttpTrigger(AuthorizationLevel.Function, "get", Route = "addtogroup/{trnantId}/{userId}")]
HttpRequestData req,
string tenantId,
string userId,
[SignalR(HubName = "testhub")]
IAsyncCollector<SignalRGroupAction> signalRGroupActions,
FunctionContext executionContext)
{
return signalRGroupActions.AddAsync(new SignalRGroupAction
{
UserId = $"{tenantId}_{userId}",
GroupName = tenantId,
Action = GroupAction.Add
});
}
}

有人可以就 .NET 5.0 中的这段代码提供指导吗?

最佳答案

正如编译器的错误所说:“...属性‘SignalROutput’在此声明类型上无效。它仅在‘方法、属性、索引器’声明上有效……”。您应该将 [SignalR(HubName = "testhub")] 属性放在方法上。这是一个sample .

您还可以在 .Net 5 sample 中看到返回类型 MyMessagesample for .NET class library function apps 中的先前 SignalRMessage 具有相同的结构| .

关于azure-functions - 在 .NET 5.0 中向 signalR 组添加/删除用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66791029/

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