peer_node_connection 1.0.0 copy "peer_node_connection: ^1.0.0" to clipboard
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
150
points
18
downloads

Publisher

unverified uploader

Weekly Downloads

A peer to peer node connection

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

typed_event_emitter, typed_messages

More

Packages that depend on peer_node_connection