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

Pass parameter #22

Closed
AliEasy opened this issue Aug 31, 2020 · 2 comments · Fixed by #26
Closed

Pass parameter #22

AliEasy opened this issue Aug 31, 2020 · 2 comments · Fixed by #26

Comments

@AliEasy
Copy link

AliEasy commented Aug 31, 2020

I need to pass Parameter(Not a token but sth like an Id) with HubConnection before _hubConnection.start()
Any help?!

@jamiewest
Copy link
Owner

Could you provide more information, code sample, documentation for supported SignalR clients demonstrating the desired result?

@AliEasy
Copy link
Author

AliEasy commented Sep 2, 2020

Could you provide more information, code sample, documentation for supported SignalR clients demonstrating the desired result?

Below is my code on Flutter:

    final connection = HubConnectionBuilder()
        .withUrl(
            'http://xxxxxx.net/',
            HttpConnectionOptions(
              transport: HttpTransportType.webSockets,
              logging: (level, message) => print(message),
            ))
        .withAutomaticReconnect()
        .build();

    await connection.start();

    connection.on("RecieveNotification", (message) {
      print(message.toString());
    });

    await connection.invoke("SendNotifications");

Also I need to send a parameter like userId

Im doing the same thing on Java and it works correctly
The code is like this:

            Platform.loadPlatformComponent(new AndroidPlatformComponent());
            Credentials credentials = new Credentials() {
                @Override
                public void prepareRequest(Request request) {
                    request.addHeader("userId", 3 + "");
                }
            };
            String serverUrl = "http://xxxxxx/";
            mHubConnection = new HubConnection(serverUrl);
            mHubConnection.setCredentials(credentials);
            String SERVER_HUB_CHAT = "notificationHub";
            mHubProxy = mHubConnection.createHubProxy(SERVER_HUB_CHAT);
            ClientTransport clientTransport = new ServerSentEventsTransport(mHubConnection.getLogger());
            SignalRFuture<Void> signalRFuture = mHubConnection.start(clientTransport);

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.

2 participants