obby_client
Write the interface. This handles IRC.
An IRCv3 engine with the client model built in, for Dart and Flutter. It parses the protocol, negotiates capabilities, authenticates, and keeps channels, members, conversations and their messages. It does no I/O: you feed it bytes and the time, it tells you what happened and what to send.
dart pub add obby_client
The engine is a native library reached through its C ABI, so your application ships libobby_ffi
and points the client at it. Every release includes a build for Linux, macOS and Windows:
github.com/obbyworld/obby-client/releases.
import 'package:obby_client/obby_client.dart';
final client = ObbyClient(nick: 'mynick', libraryPath: 'libobby_ffi.so');
client.handleConnected();
socket.listen((data) {
client.handleBytes(data);
for (final event in client.pollEvents()) render(event);
for (var bytes = client.pollTransmit(); bytes != null; bytes = client.pollTransmit()) {
socket.add(bytes);
}
});
client.join('#obby');
client.close();
Call close when finished. The engine holds native memory that Dart's collector knows nothing
about. One client belongs to one isolate: the native handle is not synchronised, so give each
isolate its own.
The async driver
ObbyAsyncClient, from package:obby_client/obby_client_async.dart, owns the loop above so you
don't have to write it: it flushes pollTransmit, ticks the clock, schedules the next tick from
pollTimeout() with a Timer, and hands you the events as a Stream.
import 'package:obby_client/obby_client_async.dart';
final socket = await Socket.connect('irc.libera.chat', 6667);
final driver = ObbyAsyncClient(socket, socket.add, nick: 'mynick');
await for (final event in driver.events) {
if (event is ObbyEventRegistered) driver.client.join('#obby');
}
The manual loop shown above still works: the async driver is an optional convenience over it, not a replacement for it.
Build from source
cargo build -p obby-ffi --release
dart pub get && dart test
Libraries
- obby_client
- The Obby IRCv3 client engine, over its C ABI.
- obby_client_async
- An async driver for ObbyClient, giving a host a
Stream<ObbyEvent>and owning the poll/drain loop for it.