peer_node_connection 1.0.0 icon indicating copy to clipboard operation
peer_node_connection: ^1.0.0 copied to clipboard

A peer to peer node connection

PeerNodeConnection #

Simple package to define peer to peer communication

for more examples visit the example section

Simple Node Example #

final node = Node();

  node.on(
    start: () {
      print('node started on port ${node.port}');
      Timer(const Duration(seconds: 3), () {
        node.stop();
      });
    },
    stop: () => print('node stopped!'),
  );

  node.start();
  await node.onNextEmit<NodeOnStopEvent>();
  print('bye bye!');

Simple Peer Example #

// connect to localhost on port 3000
final peer = Peer.local(3000);

// handle general events
peer.on(
  connect: () {
    print('connected');
    peer.sendText('hello world!');
    Timer(const Duration(seconds: 3), () {
        peer.destroy();
    });
  },
  disconnect: () {
    print('disconnected');
  }
);

peer.connect(); // start peer connection

await peer.onNextEmit<PeerOnDisconnectEvent>();
print('bye bye!');

4
likes
130
pub points
7%
popularity

Publisher

unverified uploader

A peer to peer node connection

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.BSD-3-Clause (LICENSE)

Dependencies

typed_event_emitter, typed_messages

More

Packages that depend on peer_node_connection