使用C ++客户端连接到Azure SignalR [英] Connect to Azure SignalR using a C++ client

查看:66
本文介绍了使用C ++客户端连接到Azure SignalR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以检查一下如何通过C ++客户端连接到Azure SignalR吗?

更具体地说,C ++客户端如下:
https://github.com/aspnet/SignalR/tree/release/2.2/clients/cpp

此客户端未准备好使用Azure SignalR,至少不清楚如何处理Azure中使用的AccessKey.我尝试用C#连接到Azure SignalR,在构建HubConnection时,您传递了一个生成连接的lambda. 通过Jwt传递令牌,传入Azure AccessKey.

在这种C ++情况下,如何处理Azure AccessKey?通过hub_connection并不明显,正确的方法如下:

1.从我的Azure SignalR AccessKey生成connectionToken(使用jwt?),
2.使用hub.connection将上面生成的令牌作为queryString的一部分发送,该令牌在上面的客户端中作为空字符串传递(使用uri_builder)?


Can I check how via a C++ client one can connect to Azure SignalR? 

More specifically, the C++ client is the following:
https://github.com/aspnet/SignalR/tree/release/2.2/clients/cpp

This client isn’t geared up for Azure SignalR out of the box, at least it isn't obvious how to deal with the AccessKey used in Azure. I tried connecting to Azure SignalR in C#, where when you build the HubConnection, you pass a lambda that generates a connection token via Jwt, passing in the Azure AccessKey.

In this C++ case, how do you deal with the Azure AccessKey? It isn't obvious via the hub_connection, would the correct approach be the following:

1. generate a connectionToken from my Azure SignalR AccessKey (using jwt?), 
2. send the token generated above with the hub.connection as part of the queryString, which in the client above is passed as an empty string (using uri_builder)?


推荐答案

由于现有的C ++客户端原型不具有对该服务的一流支持,因此您需要发出协商请求以获取创建集线器连接之前,请自己访问令牌和URL.这是协商端点的规范:

Since the existing C++ client prototype doesn't have first class support for the service you need to issue the negotiate request to get the access token and URL yourself before creating the hub connection. Here is the spec for the negotiate endpoint:

https://github.com/aspnet/SignalR/blob/release/2.1/specs/TransportProtocols.md#post-endpoint-basenegotiate-request

https://github.com/aspnet/SignalR/blob/release/2.1/specs/TransportProtocols.md#post-endpoint-basenegotiate-request

您对第二种类型的响应感兴趣:

You're interested in the second type of response:

{
  "url": "https://myapp.com/chat",
  "accessToken": "accessToken"
}

然后,您需要将该URL作为hub_connection的URL和accessToken放入一个名为

Then you'll need to put the URL as the URL for the hub_connection and the accessToken in a queryString called access_token. (a header works but not sure how easy that is in the current code).

希望那行得通!请随时通过https://github.com/aspnet/SignalR/issues/2385进行跟进(该团队已在该处工作)

Hopefully that works! Feel free to follow up on https://github.com/aspnet/SignalR/issues/2385 (the team is engaged there)


这篇关于使用C ++客户端连接到Azure SignalR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆