Skip to main content

air_link_room 0.2.1 copy "air_link_room: ^0.2.1" to clipboard
air_link_room: ^0.2.1 copied to clipboard

Group communication and broadcast rooms for Air Link.

Air Link Room #

Group communication and broadcast for Air Link.

A Room is a virtual group of peers. Messages sent to a room are automatically broadcast to every member.

final room = Room(name: 'game-lobby');
room.addPeer(alice);
room.addPeer(bob);

await room.broadcast('Game starting in 10 seconds!');

room.onEvent.listen((event) {
  print('${event.peer.id}: ${event.type}');
});

Quick Start #

1. Add the dependency #

dependencies:
  air_link_room: ^0.2.0

2. Create a room and add peers #

import 'package:air_link_room/air_link_room.dart';

final room = Room(name: 'chat-room');

// Add connected peers
room.addPeer(peerA);
room.addPeer(peerB);
room.addPeer(peerC);

3. Broadcast messages #

// Send to everyone
await room.broadcast('Hello everyone!');

// Listen for incoming broadcasts
room.onMessage.listen((message) {
  print('Broadcast: $message');
});

4. Listen for room events #

room.onEvent.listen((event) {
  switch (event.type) {
    case RoomEventType.peerJoined:
      print('${event.peer.id} joined');
    case RoomEventType.message:
      print('${event.peer.id}: ${event.message}');
    case RoomEventType.peerLeft:
      print('${event.peer.id} left');
  }
});

API #

Room #

Method / Property Description
Room({required String name}) Create a room with the given name
String get name The room's name
List<Peer> get peers List of currently joined peers
void addPeer(Peer peer) Add a peer to the room
void removePeer(Peer peer) Remove a peer from the room
Future<void> broadcast(String message) Send a text message to all peers
Stream<String> get onMessage Stream of received broadcast messages
Stream<RoomEvent> get onEvent Stream of room lifecycle events

RoomEvent #

Property Description
RoomEventType type Type of event (peerJoined, message, peerLeft)
Peer peer The peer that triggered the event
String? message The message content (only for message events)

Platform Support #

Platform Status
Android ✅
iOS ✅
macOS ✅
Windows ✅
Linux ✅

Module Integration #

Pair with other modules for richer group communication:

// Room + TextChannel for typing indicators
final chat = TextChannel(peer);
room.addPeer(peer);
chat.startTyping();
await room.broadcast('${peer.id} is typing…');
// Room + file transfer
final sender = FileSender(peer);
room.addPeer(peer);
// Broadcast a notification, send file privately
await room.broadcast('Sending photo…');
await sender.share(photoFile);

Requirements #

  • Dart SDK >=3.0.0 <4.0.0
  • Depends on air_link_core

License #

MIT

0
likes
160
points
47
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Group communication and broadcast rooms for Air Link.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

air_link_core

More

Packages that depend on air_link_room