如何解决天蓝色功能
在使用客户端UI连接生成器协商azure函数中的连接后,如何在azure函数中存在从azure signalR向特定用户发送数据的方法。在azure函数目标中存在。在UI中使用javascript的用户ID的任何完整解决方案用户ID如何可以传递给Azure Function并使用SignalR将数据发送给特定用户
谈判
[FunctionName("negotiate")]
public static SignalRConnectionInfo GetorderNotificationsSignalRInfo(
[HttpTrigger(AuthorizationLevel.Anonymous,"post")] HttpRequest req,[SignalRConnectionInfo(HubName = "notifications")] SignalRConnectionInfo connectionInfo)
{
return connectionInfo;
}
SignalR代码
[FunctionName("PlacedOrderNotification")]
public static async Task Run(
[QueueTrigger("new-order-notifications")] OrderPlacement orderPlacement,[SignalR(HubName = "notifications")] IAsyncCollector<SignalRMessage> signalRMessages,ILogger log)
{
log.Loginformation($"Sending notification for {orderPlacement.CustomerName}");
await signalRMessages.AddAsync(
new SignalRMessage
{
Target = "productOrdered",Arguments = new[] { orderPlacement }
});
}
UI-Javascript
const connection = new signalR.HubConnectionBuilder()
.withUrl('http://localhost:7071/api')
.configureLogging(signalR.LogLevel.information)
.build();
connection.on('productOrdered',(productOrdered));
connection.onclose(() => console.log('disconnected'));
console.log('connecting...');
connection.start()
.then(() => data.ready = true)
.catch(console.error);
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。