signalr_socket 1.1.4 copy "signalr_socket: ^1.1.4" to clipboard
signalr_socket: ^1.1.4 copied to clipboard

A flutter plugin for aspx.net SignalR client for Android, iOS, macOS and Web

signalr_socket #

pub package

A flutter plugin for aspx.net SignalR client for Android, iOS, macOS and Web

Getting Started #

Note: This library is NOT compatible with ASP.NET Core SignalR

Add dependency #

dependencies:
  signalr_socket: ^1.1.4 #latest version

Initialize SignalR Socket & connect to server.

SignalrSocket signalrSocket = SignalrSocket(
  url: 'https://signalr.socket.com',
  hubName: 'hubName',
  eventName: 'eventName',
  queryString: {'key': 'value'},
  updateConnectionStatus: (status) {
    debugPrint("signalr socket update connection status ${status.name}");
  },
  newMessage: (message) {
    debugPrint("signalr socket new message $message");
  },
);

signalrSocket.connect();

Android Setup #

  • Add proguard rules for release mode in android
  • Create a new file in your android project: android/app/proguard-rules.pro
  • Add the following lines to the proguard-rules.pro
-keep class com.github.signalr4j.client.hubs.HubResult { *; }
-keep class com.github.signalr4j.client.hubs.HubInvocation { *; }
-keep class com.github.signalr4j.client.hubs.HubProxy$* { *; }
-keep class com.github.signalr4j.client.hubs.HubConnection {*;}

If you want a HTTP url, then you need to add the following lines to the manifest of your android project.

<application
        android:usesCleartextTraffic="true">
</application>

Web Setup #

<head>
    <!--other lines-->

    <script defer type="application/javascript" src="signalR_js/jquery.min.js"></script>
    <script defer type="application/javascript" src="signalR_js/jquery.signalR-2.4.3.min.js"></script>
    <script defer type="application/javascript" src="signalR_js/socketConnection.js"></script>
</head>
4
likes
110
pub points
43%
popularity

Publisher

unverified uploader

A flutter plugin for aspx.net SignalR client for Android, iOS, macOS and Web

Repository (GitHub)
View/report issues

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter, flutter_web_plugins, js, plugin_platform_interface

More

Packages that depend on signalr_socket