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

How to Use #21

Closed
AliEasy opened this issue Aug 31, 2020 · 1 comment
Closed

How to Use #21

AliEasy opened this issue Aug 31, 2020 · 1 comment

Comments

@AliEasy
Copy link

AliEasy commented Aug 31, 2020

Im new to Flutter frameWork
I want to use signalr on flutter to connect to a server and receive notification
below code is how I do it on Java:

        Platform.loadPlatformComponent(new AndroidPlatformComponent());
        Credentials credentials = new Credentials() {
            @Override
             public void prepareRequest(Request request) {
                request.addHeader("username", userId);
            }
        };
        String serverUrl = "http://www.xxxxx.org/";
        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);

        try {
            signalRFuture.get();
        } catch (Exception ex) {
            UtilFunctions.showToastMessage(getApplicationContext(), ex);
            return;
        }

        String SERVER_METHOD_SEND = "SendNotifications";
        mHubProxy.invoke(SERVER_METHOD_SEND);

        mHubProxy.on("ReceiveNotification", new SubscriptionHandler1<String>() {
            @Override
            public void run(final String string) {
               ......
            }
        }, String.class);

But Im not able to implement on flutter
ppreciate any help.
Thanks in advance.

@jamiewest
Copy link
Owner

I have not had time to work on documentation, I would recommend looking at JavaScript examples for the SignalRCore client and hopefully they might make creating a dart equivalent easier.

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

No branches or pull requests

2 participants