zaptools_client 0.4.1 copy "zaptools_client: ^0.4.1" to clipboard
zaptools_client: ^0.4.1 copied to clipboard

A toolkit for Event-Driven websocket management, compatible with pure websocket or zaptool server.

Zaptools #

A toolkit for Event-Driven websocket management

Getting started #

Zaptools provides tools for building event-driven websocket integration. It is built on top websocket.

Usage #

In order to get a connection with the server, zaptools-dart provides a client based on callbacks.

ZapConsumer trigger a callback when a event is invoked

  final zConsumer = ZapConsumer('ws://127.0.0.1:8000/')..connect();

  zConsumer.onConnected((eventData) {
    print('connected!');
  });

  zConsumer.onDisconnected((eventData) {
    print('disconnected!');
  });

  zConsumer.onEvent("myEvent", (eventData) { 
    print("myEvent Received");
  });

  zConsumer.onAnyEvent((eventData) {
    print("event received");
  });


Sending Event

Both ZapConsumer and ZapSubscriber can send events to the server by the method send

zConsumer.sendEvent("eventName", "payload");

Connect, Disconnect, tryReconnect

connect method is used for both intitial connections and reconnections to the server in case connection lost.

zConsumer.connect();

disconnect method, close the websocket connection with the server.

zConsumer.disconnect();

Contributions are wellcome! #

6
likes
150
points
62
downloads
screenshot

Publisher

unverified uploader

Weekly Downloads

A toolkit for Event-Driven websocket management, compatible with pure websocket or zaptool server.

Repository (GitHub)

Topics

#websocket #client #realtime

Documentation

API reference

License

MIT (license)

Dependencies

uuid, web_socket_channel

More

Packages that depend on zaptools_client