Skip to content

Commit

Permalink
Websocket client tool results (#12)
Browse files Browse the repository at this point in the history
This fixes large tool results sometimes failing to reach our server
  • Loading branch information
mdepinet authored Dec 14, 2024
1 parent 7a95aa1 commit 4fd1e42
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
* Use simplifed `transcript` messages.
* Expose `sendData` and `dataMessageNotifier` for bleeding edge use cases.
* Update dependencies.

# 0.0.8

* Send large data messages over our websocket instead of the WebRTC data channel to avoid dropped UDP packets.
13 changes: 7 additions & 6 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,13 @@ packages:
source: hosted
version: "1.0.8"
dart_webrtc:
dependency: transitive
dependency: "direct overridden"
description:
name: dart_webrtc
sha256: c664ad88d5646735753add421ee2118486c100febef5e92b7f59cdbabf6a51f6
url: "https://pub.dev"
source: hosted
path: "."
ref: HEAD
resolved-ref: e78507fdcc2b46621a389607e16f92fa942befd7
url: "https://github.com/flutter-webrtc/dart-webrtc.git"
source: git
version: "1.4.9"
dbus:
dependency: transitive
Expand Down Expand Up @@ -475,7 +476,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.7"
version: "0.0.8"
uuid:
dependency: transitive
description:
Expand Down
7 changes: 7 additions & 0 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,10 @@ dev_dependencies:

flutter:
uses-material-design: true

# Temporary fix for flutter 3.27.0 incompatibility with dart_webrtc 1.4.9
dependency_overrides:
dart_webrtc:
git:
url: https://github.com/flutter-webrtc/dart-webrtc.git
ref: f27d27c7af41ceeebe31b295af4fb38e7b4d793e
10 changes: 7 additions & 3 deletions lib/src/session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:livekit_client/livekit_client.dart' as lk;
import 'package:web_socket_channel/web_socket_channel.dart';
import 'dart:convert';

const ultravoxSdkVersion = '0.0.7';
const ultravoxSdkVersion = '0.0.8';

/// The current status of an [UltravoxSession].
enum UltravoxSessionStatus {
Expand Down Expand Up @@ -320,8 +320,12 @@ class UltravoxSession {
throw Exception("Data must contain a 'type' key");
}
final message = jsonEncode(data);
await _room.localParticipant
?.publishData(utf8.encode(message), reliable: true);
final messageBytes = utf8.encode(message);
if (messageBytes.length > 1024) {
_wsChannel.sink.add(message);
} else {
await _room.localParticipant?.publishData(messageBytes, reliable: true);
}
}

Future<void> _disconnect() async {
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: ultravox_client
description: "Flutter client SDK for Ultravox."
version: 0.0.7
version: 0.0.8
homepage: https://ultravox.ai
repository: https://github.com/fixie-ai/ultravox-client-sdk-flutter
topics:
Expand Down

0 comments on commit 4fd1e42

Please sign in to comment.