Closed jasson120 closed 3 years ago
I believe what you would want to use is the accessTokenFactory
property on the HttpConnectionOptions
class to pass connection related tokens to the server.
Example
final connection = HubConnectionBuilder()
.withUrl('http://example.com',
HttpConnectionOptions(accessTokenFactory: () => 'MyAccessToken'))
.build();
No, I would like to send the metadata in the URL to the hub for example userId. When I added parameter userId in URL("https://test.com/Hub?userId=24), then your function "_createConnectUrl" added some own parameter id=$connectionToken and resulting URL in HUB is "test.com/Hub?userId=24?id=connectionToken" and the correct result should be "test.com/Hub?userId=24&id=connectionToken".
The article what I mean: https://buildingsteps.wordpress.com/2018/10/14/signalr-metadata-for-asp-net-core-2-1/
I think you have a solution but you have it commented in function _createConnectUrl.
//return url + (url.contains('?') ? '?' : '&') + 'id=$connectionToken'; }
Hi, you have TODO in code:
static String _createConnectUrl(String url, String connectionToken) { if (connectionToken == null) { return url; } // TODO: Look at this... return url + '?' + 'id=$connectionToken'; //return url + (url.contains('?') ? '?' : '&') + 'id=$connectionToken'; }
And my question is do you plan change this TODO? because in this case is difficult pass data. When i set in url for example "https://test.com/Hub?userId=24" i get in server this one "https://test.com/Hub?userId=24?id=connectionToken"