Multiple Hubs per Function with OnConnected Method
Closed this issue · 2 comments
phantomcosmonaut commented
I have two class-based model hubs exposed by the same Function, however The OnConnected
method name is problematic because a function cannot have duplicate names and I cannot use binding or I get the following error:
The 'OnConnected' function is in error: Microsoft.Azure.WebJobs.Host: Error indexing method 'OnConnected'. Microsoft.Azure.WebJobs.Extensions.SignalRService: SignalRTriggerAttribute must use parameterless constructor in class based model.
class FooHub : ServerlessHub
{
[FunctionName(nameof(NegotiateFoo))]
public Task<SignalRConnectionInfo> NegotiateFoo([HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequest httpRequest, ILogger logger)
{
...
}
[FunctionName(nameof(OnConnected))]
public async Task OnConnected([SignalRTrigger] InvocationContext invocationContext, ILogger logger)
{
...
}
}
class BarHub : ServerlessHub
{
[FunctionName(nameof(NegotiateBar))]
public Task<SignalRConnectionInfo> NegotiateBar([HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequest httpRequest, ILogger logger)
{
...
}
[FunctionName(nameof(OnConnected))]
public async Task OnConnected([SignalRTrigger] InvocationContext invocationContext, ILogger logger)
{
...
}
}
Y-Sindo commented
You can change [FunctionName(nameof(OnConnected))]
to other names, as long as the C# function name is OnConnected
phantomcosmonaut commented
oh wow, thought the auto binding was coming from function name. Thanks!