obby_client 0.3.0 copy "obby_client: ^0.3.0" to clipboard
obby_client: ^0.3.0 copied to clipboard

The Obby IRCv3 client engine, over its C ABI.

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: https://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
0
likes
140
points
222
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

The Obby IRCv3 client engine, over its C ABI.

Homepage
Repository (GitHub)
View/report issues
Contributing

License

GPL-3.0 (license)

Dependencies

ffi

More

Packages that depend on obby_client