Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing data on connection #13

Closed
jasson120 opened this issue Apr 28, 2020 · 3 comments · Fixed by #26
Closed

Passing data on connection #13

jasson120 opened this issue Apr 28, 2020 · 3 comments · Fixed by #26

Comments

@jasson120
Copy link

jasson120 commented Apr 28, 2020

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"

@jamiewest
Copy link
Owner

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();

@jasson120
Copy link
Author

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'; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants