wamp_client 0.6.0 copy "wamp_client: ^0.6.0" to clipboard
wamp_client: ^0.6.0 copied to clipboard

A library for WAMP protocol client. WAMP is the Web Application Messaging Protocol (https://wamp-proto.org)

example/wamp_client_example.dart

import 'dart:async';
import 'package:wamp_client/wamp_client.dart';

Future main() async {
  var wamp = new WampClient('realm1',
      auth: WampAuth.wampcra(
        id: 'client1',
        secret: 'secret123',
      ))
    ..onConnect = (c) {
      c.subscribe('topic').then((s) async {
        await for (final ev in s) {
          print('ev $ev');
          //return;
        }
      });
      print('start sub');

      c.publish('topic').then((dynamic _) {
        print('published');
      });

      final pname = 'proc.17';

      c.register(pname, (a) {
        print('proc arg: $a');
        //throw new WampArgs(<dynamic>[100], <String, dynamic>{'test': true});
        return a;
      }).then((WampRegistration regid) async {
        print('register ok $regid');

        await c.call(pname, <dynamic>[2, 3],
            <String, dynamic>{'hello': 'world!'}).then((r) {
          print('result ${r.args} ${r.params}');
        }).catchError((dynamic e) {
          print('call err $e');
        });

        await c.unregister(regid);
        print('unregister ok');
      }).catchError((dynamic e) {
        print('register error $e');
      });
    };
  await wamp.connect('ws://localhost:8080/ws');
}
2
likes
120
pub points
43%
popularity

Publisher

verified publisherkkazuo.com

A library for WAMP protocol client. WAMP is the Web Application Messaging Protocol (https://wamp-proto.org)

Repository (GitHub)
View/report issues

Documentation

API reference

License

ISC (LICENSE)

Dependencies

crypto

More

Packages that depend on wamp_client