【发布时间】:2021-05-27 16:15:56
【问题描述】:
带有signalR输入绑定的天蓝色函数可以获取一些参数。 例如
[FunctionName("SignalRTest")]
public async Task SendMessage([SignalRTrigger]InvocationContext invocationContext, string message, ILogger logger)
{
logger.LogInformation($"Receive {message} from {invocationContext.ConnectionId}.");
}
在函数中它可以调用客户端,例如
[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 this user ID
UserId = "userId1",
Target = "newMessage",
Arguments = new [] { message }
});
}
但是带有输入绑定的 azure 函数是否有可能返回一些东西?
我想要
[FunctionName("SignalRTest")]
public async Task<string> SendMessage([SignalRTrigger]InvocationContext invocationContext, string message, ILogger logger)
{
return "123";
}
和
id = connection.invoke("SendMessage", "test");
但它似乎不起作用。
谢谢。
【问题讨论】:
标签: azure azure-functions signalr azure-signalr