Skip to main content

ws_native 2.0.0-dev.2 copy "ws_native: ^2.0.0-dev.2" to clipboard
ws_native: ^2.0.0-dev.2 copied to clipboard

Native (Rust) transport for the ws WebSocket client: TLS, framing and JSON parsing off the Dart thread. Install it with WsNative.install().

example/main.dart

// Echo through the Rust transport. Run with `dart run example/main.dart`
// from native/ (the build hook bundles the library).
import 'dart:io';

import 'package:ws/ws.dart';
import 'package:ws_native/ws_native.dart';

Future<void> main() async {
  if (!WsNative.install()) {
    stderr.writeln('pure Dart transport: ${WsNative.unavailableReason}');
  }
  final client = WebSocketClient.text();
  client.messages.listen(print);
  await client.connect('wss://ws.postman-echo.com/raw');
  print('transport: ${client.metrics.transport}');
  await client.push('hello');
  await Future<void>.delayed(const Duration(seconds: 1));
  await client.close();
}
0
likes
150
points
--
downloads

Documentation

API reference

Publisher

verified publisherplugfox.dev

Weekly Downloads

Native (Rust) transport for the ws WebSocket client: TLS, framing and JSON parsing off the Dart thread. Install it with WsNative.install().

Topics

#websocket #ffi #rust #native-assets

License

MIT, Unicode-3.0, Zlib (license)

Dependencies

code_assets, crypto, hooks, meta, ws

More

Packages that depend on ws_native