Skip to content

API Reference

Initialize

Firstly, call WaterbusSdk.instance.initial to set your server url and sdk connect WebSocket.

await WaterbusSdk.instance.initializeApp(
apiUrl: 'https://service.waterbus.tech/busapi/v1/',
wsUrl: 'wss://sfu.waterbus.tech',
privateMessageKey: "waterbus@2024",
);

Authorization

Create Token

Create token will auto connect websocket if success

await WaterbusSdk.instance.createToken(payload);

Refresh Token

await WaterbusSdk.instance.renewToken();

Delete Token

Delete token for disconnect websocket and prepare for create new token

await WaterbusSdk.instance.deleteToken();

Meeting

Create room

final Meeting? meeting = await WaterbusSdk.instance.createRoom(
meeting: Meeting(title: 'Meeting with Kai Dao'),
password: 'password',
userId: 1, // <- modify to your user id
);

Update room

final Meeting? meeting = await WaterbusSdk.instance.updateRoom(
meeting: Meeting(title: 'Meeting with Kai Dao - 2'),
password: 'new-password',
userId: 1, // <- modify to your user id
);

Join room

final Meeting? meeting = await WaterbusSdk.instance.joinRoom(
meeting: _currentMeeting,
password: 'room-password-here',
userId: 1, // <- modify to your user id
);

Leave room

await WaterbusSdk.instance.leaveRoom();

Prepare Media

await WaterbusSdk.instance.prepareMedia();

Set callback

  • Callback event
void _onEventChanged(CallbackPayload event) {
switch (event.event) {
case CallbackEvents.shouldBeUpdateState:
break;
case CallbackEvents.newParticipant:
break;
case CallbackEvents.participantHasLeft:
break;
case CallbackEvents.meetingEnded:
break;
default:
break;
}
}
WaterbusSdk.instance.onEventChangedRegister = _onEventChanged;
  • Callback subtitle
void _onSubtitleChanged(Subtitle sub) {
print('${sub.participant}: ${sub.content}');
}
WaterbusSdk.instance.setOnSubtitle = _onSubtitleChanged;
  • Callback video sender stats
void _handleOnStatsChanged(VideoSenderStats stats) {
print(stats.toString());
}
WaterbusSdk.onStatsChanged = _handleOnStatsChanged;