Closed AliEasy closed 4 years ago
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.
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.
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:
But Im not able to implement on flutter ppreciate any help. Thanks in advance.