kabelwerk library

Welcome to the documentation of the Kabelwerk SDK for Dart!

Connection

The entry point is to create and configure an instance of the Kabelwerk class, which opens and maintains the websocket connection to the Kabelwerk server.

final kabelwerk = Kabelwerk();

kabelwerk.config
  ..url = kabelwerkServerUrl
  ..token = myAuthToken;

kabelwerk.on('ready', (KabelwerkReadyEvent event) {
  // this event is fired once when the initial connection is established
  final inbox = kabelwerk.openInbox();
  final room = kabelwerk.openRoom();
});

kabelwerk.on('error', (ErrorEvent event) {
  // e.g. when the token is invalid
});

kabelwerk.connect();

A Kabelwerk instance takes care of automatically re-connecting when the connection drops, opening inboxes, notifiers, and rooms (see below), as well as retrieving and updating the connected user's info.

Inboxes

An Inbox is a view on the rooms the user has access to; it maintains a list of rooms ordered by recency of their latest message.

final inbox = kabelwerk.openInbox();

inbox.on('ready', (InboxReadyEvent event) {
  // this event is fired once when the initial list of inbox items is loaded
});

inbox.on('updated', (InboxUpdatedEvent event) {
  // whenever a new message is posted, the list of inbox items is updated
  // accordingly and this event is fired
});

inbox.connect();

Rooms

A Room handles posting and retrieving messages in a chat room.

final room = kabelwerk.openRoom(roomId);

room.on('ready', (RoomReadyEvent event) {
  // this event is fired once when the room is loaded
});

room.on('message_posted', (MessagePostedEvent event) {
  // this event is fired every time a new message is posted in this room
});

room.connect();

room.postMessage(text: text).then((message) {
  // you will also get the same message via the `message_posted` event
});

You can open as many rooms as you need. However, if you just want to listen for newly posted messages, then it is simpler to leverage the InboxUpdatedEvent event.

Classes

Config
The configuration of a Kabelwerk instance.
ConnectedEvent
A Kabelwerk event fired when the connection to the server is first established.
Device
The currently connected device.
DisconnectedEvent
A Kabelwerk event fired when the connection to the server is dropped.
ErrorEvent
An event fired when there is a problem establishing connection to the server (e.g. because of a timeout).
Event
The base class for all events in the library.
Hub
A Kabelwerk hub.
Inbox
An inbox is a view on the rooms the user has access to; it maintains a list of rooms ordered by recency of their latest message.
InboxItem
An inbox item.
InboxReadyEvent
An Inbox event fired when the connection to the server is first established and the Inbox instance is ready to be used.
InboxUpdatedEvent
An Inbox event fired when any of the inbox items changes.
Kabelwerk
A Kabelwerk instance opens and maintains a websocket connection to the Kabelwerk backend; it is also used for retrieving and updating the connected user's info, opening inboxes and notifiers, and creating and opening rooms.
KabelwerkReadyEvent
A Kabelwerk event fired when the connection to the server is first established and the Kabelwerk instance is ready to be used.
Marker
A marker on a message in a room.
MarkerMovedEvent
A Room event fired when a marker in the room is updated or created (by any user).
Message
A chat message.
MessageDeletedEvent
A Room event fired when a message is deleted from the room (by any user).
MessagePostedEvent
A Room event fired when there is a new message posted in the room (by any user).
Notifier
A notifier emits events intended to be used for implementing client-side notifications.
NotifierReadyEvent
A Notifier event fired when the Notifier instance has first established connection to the server and is ready to be used.
NotifierUpdatedEvent
A Notifier event fired when there is a new message posted in any of the rooms that the connected user has access to.
Room
A room is where chat messages are exchanged between an end user on one side and your care team (hub users) on the other side.
RoomReadyEvent
A Room event fired when the connection to the server is first established and the Room instance is ready to be used.
Upload
An upload.
User
A Kabelwerk user.
UserUpdatedEvent
A Kabelwerk event fired when the connected user's name has changed.

Enums

ConnectionState
The possible states of the websocket connection to the Kabelwerk backend.
MessageType
The possible chat message types.