ObbyClient class
One connection.
Call close when finished. The engine holds native memory that Dart's collector knows nothing about, so nothing releases it on your behalf.
One client belongs to one isolate. The native handle is not synchronised, so sending its address to another isolate and rebuilding it there is undefined behaviour, not merely a race. Give each isolate its own client.
final client = ObbyClient(nick: 'me');
final socket = await Socket.connect('irc.libera.chat', 6667);
client.handleConnected();
socket.listen((chunk) {
client.handleBytes(chunk);
client.tick(stopwatch.elapsedMilliseconds, DateTime.now().millisecondsSinceEpoch);
for (final event in client.pollEvents()) {
if (event['type'] == 'registered') {
client.join('#obby');
client.sendMessage('#obby', 'hello');
}
}
for (var out = client.pollTransmit(); out != null; out = client.pollTransmit()) {
socket.add(out);
}
});
Constructors
-
ObbyClient({required String nick, String? username, String? realname, String? password, SaslCredentialsInput? sasl, int? retention, List<
String> ? altNicks, String? libraryPath}) -
Open a connection's engine.
factory
-
ObbyClient.fromConfig(Map<
String, dynamic> config, {String? libraryPath}) -
Open a connection's engine from a config map already in the wire shape.
factory
Properties
Methods
-
addReaction(
String target, String msgid, String emoji) → void - React to a message with an emoji.
-
close(
) → void - Release the engine. Safe to call more than once.
-
command(
Map< String, dynamic> command) → bool - Do something on this connection, as a command map the host built itself.
-
createInviteLink(
{String? channel, String? description}) → void - Make an invitation link to a channel, or to the network when no channel is named.
-
deleteInviteLink(
) → void - Withdraw an invitation link.
-
fetchHistory(
String target, {String? beforeMsgid, int limit = 50}) → void - Ask for older messages than the ones we hold.
-
generateToken(
String service) → void - Mint a bearer token for one of the network's services, such as its file host.
-
handleBytes(
Uint8List data) → void - Feed whatever the transport read. Partial lines are held until the rest arrives.
-
handleConnected(
) → void - Tell the engine the transport is up. Queues the registration burst.
-
handleDisconnected(
) → void - Tell the engine its transport died. The model survives, so a reconnect resumes from it.
-
join(
String channel, {String? key}) → void - Join a channel, with its key when it has one.
-
listInviteLinks(
) → void - Ask for the invitation links we have made.
-
markRead(
String target, int atMs) → void - Tell the server how far we have read, in milliseconds since the Unix epoch.
-
model(
) → Model - Everything the connection knows: channels, members, conversations, messages.
-
modelJson(
) → Map< String, dynamic> - Everything the connection knows, as the raw wire map, for a host that wants the escape hatch rather than the typed model.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
part(
String channel, {String? reason}) → void - Leave a channel.
-
pollEvents(
) → List< ObbyEvent> - Every event queued since the last call, as the typed ObbyEvent.
-
pollEventsJson(
) → List< Map< String, dynamic> > - Every event queued since the last call, as the raw wire map, for a host that wants the escape hatch rather than the typed pollEvents.
-
pollTimeout(
) → int? - When tick next has something to do, or null when nothing is scheduled.
-
pollTransmit(
) → Uint8List? - Bytes to write to the transport, or null when there are none.
-
quit(
{String? reason}) → void - Leave the network.
-
redactMessage(
String target, String msgid, {String? reason}) → void - Ask the server to delete a message.
-
redeemInviteCode(
String code) → void - Redeem an invitation code. Only before registering, which is the point of it.
-
removeReaction(
String target, String msgid, String emoji) → void - Take a reaction back.
-
renameChannel(
String channel, String newName, {String? reason}) → void - Rename a channel, keeping everyone in it and everything said in it.
-
sendAction(
String target, String text) → void -
Send a
CTCP ACTION, the third-person form. -
sendMessage(
String target, String text) → void - Say something to a channel or a person.
-
sendNotice(
String target, String text) → void - Send a notice, which by convention must never be auto-replied to.
-
sendRawLine(
String line) → void - Send a line the engine does not model. The escape hatch, so you are never stuck waiting on it.
-
sendVoiceSignal(
String channel, VoiceSignal signal) → void - Send a voice signalling frame to a room.
-
setAway(
{String? message}) → void - Mark ourselves away, or come back.
-
setMetadata(
String key, {String? value}) → void - Set one of our own metadata keys, or clear it.
-
setNick(
String nick) → void - Change our nick.
-
setTopic(
String channel, {String? topic}) → void - Set or clear a channel topic.
-
setTyping(
String target, TypingState state) → void - Say we are typing, so others can show it.
-
subscribeMetadata(
List< String> keys) → void - Ask to be told when these metadata keys change on anyone we can see.
-
tick(
int monotonicMs, int unixMs) → void -
Advance the clock.
monotonicMsdrives every deadline;unixMsonly stamps a message the server did not stamp itself. -
toString(
) → String -
A string representation of this object.
inherited
-
unwatchNicks(
List< String> nicks) → void - Stop watching these nicks.
-
watchNicks(
List< String> nicks) → void - Watch these nicks, so the server says when they come and go.
-
whois(
String nick) → void - Ask the server everything it will say about someone.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited