Skip to content

Commit 6bcd081

Browse files
bugfix new release
1 parent 23605e4 commit 6bcd081

File tree

8 files changed

+64
-45
lines changed

8 files changed

+64
-45
lines changed

.flutter-plugins

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This is a generated file; do not edit or check into version control.
2-
flutter_webrtc=/Users/utopia/.pub-cache/hosted/pub.dev/flutter_webrtc-0.13.0/
2+
flutter_webrtc=/Users/utopia/.pub-cache/hosted/pub.dev/flutter_webrtc-0.14.1/
33
path_provider=/Users/utopia/.pub-cache/hosted/pub.dev/path_provider-2.1.5/
44
path_provider_android=/Users/utopia/.pub-cache/hosted/pub.dev/path_provider_android-2.2.16/
55
path_provider_foundation=/Users/utopia/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.1/

.flutter-plugins-dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_webrtc","path":"/Users/utopia/.pub-cache/hosted/pub.dev/flutter_webrtc-0.13.0/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/Users/utopia/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"flutter_webrtc","path":"/Users/utopia/.pub-cache/hosted/pub.dev/flutter_webrtc-0.13.0/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"/Users/utopia/.pub-cache/hosted/pub.dev/path_provider_android-2.2.16/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"flutter_webrtc","path":"/Users/utopia/.pub-cache/hosted/pub.dev/flutter_webrtc-0.13.0/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/Users/utopia/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[{"name":"flutter_webrtc","path":"/Users/utopia/.pub-cache/hosted/pub.dev/flutter_webrtc-0.13.0/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_linux","path":"/Users/utopia/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[],"dev_dependency":false}],"windows":[{"name":"flutter_webrtc","path":"/Users/utopia/.pub-cache/hosted/pub.dev/flutter_webrtc-0.13.0/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_windows","path":"/Users/utopia/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[],"dev_dependency":false}],"web":[]},"dependencyGraph":[{"name":"flutter_webrtc","dependencies":["path_provider"]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2025-05-05 04:05:08.924445","version":"3.29.3","swift_package_manager_enabled":{"ios":false,"macos":false}}
1+
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_webrtc","path":"/Users/utopia/.pub-cache/hosted/pub.dev/flutter_webrtc-0.14.1/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/Users/utopia/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"android":[{"name":"flutter_webrtc","path":"/Users/utopia/.pub-cache/hosted/pub.dev/flutter_webrtc-0.14.1/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_android","path":"/Users/utopia/.pub-cache/hosted/pub.dev/path_provider_android-2.2.16/","native_build":true,"dependencies":[],"dev_dependency":false}],"macos":[{"name":"flutter_webrtc","path":"/Users/utopia/.pub-cache/hosted/pub.dev/flutter_webrtc-0.14.1/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_foundation","path":"/Users/utopia/.pub-cache/hosted/pub.dev/path_provider_foundation-2.4.1/","shared_darwin_source":true,"native_build":true,"dependencies":[],"dev_dependency":false}],"linux":[{"name":"flutter_webrtc","path":"/Users/utopia/.pub-cache/hosted/pub.dev/flutter_webrtc-0.14.1/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_linux","path":"/Users/utopia/.pub-cache/hosted/pub.dev/path_provider_linux-2.2.1/","native_build":false,"dependencies":[],"dev_dependency":false}],"windows":[{"name":"flutter_webrtc","path":"/Users/utopia/.pub-cache/hosted/pub.dev/flutter_webrtc-0.14.1/","native_build":true,"dependencies":[],"dev_dependency":false},{"name":"path_provider_windows","path":"/Users/utopia/.pub-cache/hosted/pub.dev/path_provider_windows-2.3.0/","native_build":false,"dependencies":[],"dev_dependency":false}],"web":[]},"dependencyGraph":[{"name":"flutter_webrtc","dependencies":["path_provider"]},{"name":"path_provider","dependencies":["path_provider_android","path_provider_foundation","path_provider_linux","path_provider_windows"]},{"name":"path_provider_android","dependencies":[]},{"name":"path_provider_foundation","dependencies":[]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_windows","dependencies":[]}],"date_created":"2025-05-28 22:54:02.875283","version":"3.29.3","swift_package_manager_enabled":{"ios":false,"macos":false}}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 2.3.9
2+
- bugfix: websocket session send refactored to use Completer instead of error prone firstWhere
3+
14
## 2.3.8
25
- bugfix: Data isn't serialized [#178](https://github.com/flutterjanus/flutter_janus_client/pull/178)
36

example/pubspec.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ packages:
109109
dependency: transitive
110110
description:
111111
name: dartdoc
112-
sha256: eb152ab07c585adb11cc24b7b93280a02f6ac5ff724cca4e6cabb24e8be88c82
112+
sha256: f978526530e42dbb831295af743c057d94533e89c27ce1f4023b252f3d85b8be
113113
url: "https://pub.dev"
114114
source: hosted
115-
version: "8.3.3"
115+
version: "8.3.4"
116116
fake_async:
117117
dependency: transitive
118118
description:
@@ -172,10 +172,10 @@ packages:
172172
dependency: transitive
173173
description:
174174
name: flutter_webrtc
175-
sha256: "23af761bb812e6f32c34263e62df48aaf26bb08582c8be8cc3170e2a018d1155"
175+
sha256: dd47ca103b5b6217771e6277882674276d9621bbf9eb23da3c03898b507844e3
176176
url: "https://pub.dev"
177177
source: hosted
178-
version: "0.13.1+hotfix.1"
178+
version: "0.14.1"
179179
glob:
180180
dependency: transitive
181181
description:
@@ -196,10 +196,10 @@ packages:
196196
dependency: transitive
197197
description:
198198
name: http
199-
sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f
199+
sha256: "2c11f3f94c687ee9bad77c171151672986360b2b001d109814ee7140b2cf261b"
200200
url: "https://pub.dev"
201201
source: hosted
202-
version: "1.3.0"
202+
version: "1.4.0"
203203
http_parser:
204204
dependency: transitive
205205
description:
@@ -214,7 +214,7 @@ packages:
214214
path: ".."
215215
relative: true
216216
source: path
217-
version: "2.3.6"
217+
version: "2.3.9"
218218
js:
219219
dependency: transitive
220220
description:

lib/janus_session.dart

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ class JanusSession {
3535
if (!ws.isConnected) {
3636
ws.connect();
3737
}
38-
ws.sink!.add(stringify(request));
39-
response = parse(await ws.stream.firstWhere((element) => (parse(element)['transaction'] == transaction)));
38+
response=await ws.send(request, handleId: null);
4039
if (response!.containsKey('janus') && response.containsKey('data')) {
4140
_sessionId = response['data']['id'] as int?;
4241
ws.sessionId = sessionId;
@@ -100,8 +99,7 @@ class JanusSession {
10099
if (!ws.isConnected) {
101100
ws.connect();
102101
}
103-
ws.sink!.add(stringify(request));
104-
response = parse(await ws.stream.firstWhere((element) => (parse(element)['transaction'] == transaction)));
102+
response = await ws.send(request, handleId: null);
105103
if (response!.containsKey('janus') && response.containsKey('data')) {
106104
handleId = response['data']['id'] as int?;
107105
_context._logger.fine(response);
@@ -146,9 +144,8 @@ class JanusSession {
146144
_context._logger.finest("not connected trying to establish connection to webSocket");
147145
ws.connect();
148146
}
149-
ws.sink!.add(stringify({"janus": "keepalive", "session_id": sessionId, "transaction": transaction, ..._context._apiMap, ..._context._tokenMap}));
147+
response = await ws.send({"janus": "keepalive", "session_id": sessionId, "transaction": transaction, ..._context._apiMap, ..._context._tokenMap}, handleId: null);
150148
_context._logger.finest("keepalive request sent to webSocket");
151-
response = parse(await ws.stream.firstWhere((element) => (parse(element)['transaction'] == transaction)));
152149
_context._logger.finest(response);
153150
}
154151
} catch (e) {

lib/janus_transport.dart

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class WebSocketJanusTransport extends JanusTransport {
7373
WebSocketSink? sink;
7474
late Stream stream;
7575
bool isConnected = false;
76+
final Map<String, Completer<dynamic>> _pendingTransactions = {};
7677

7778
void dispose() {
7879
if (channel != null && sink != null) {
@@ -82,30 +83,40 @@ class WebSocketJanusTransport extends JanusTransport {
8283
}
8384

8485
/// this method is used to send json payload to Janus Server for communicating the intent.
85-
Future<dynamic> send(Map<String, dynamic> data, {int? handleId}) async {
86-
if (data['transaction'] != null) {
87-
data['session_id'] = sessionId;
88-
if (handleId != null) {
89-
data['handle_id'] = handleId;
90-
}
91-
sink!.add(stringify(data));
92-
return parse(await stream.firstWhere((element) => (parse(element)['transaction'] == data['transaction']), orElse: () => {}));
93-
} else {
94-
throw "transaction key missing in body";
86+
Future<dynamic> send(Map<String, dynamic> data, {int? handleId}) {
87+
final transaction = data['transaction'];
88+
89+
if (transaction == null) {
90+
throw Exception("transaction key missing in body");
91+
}
92+
93+
data['session_id'] = sessionId;
94+
if (handleId != null) {
95+
data['handle_id'] = handleId;
9596
}
97+
98+
final completer = Completer<dynamic>();
99+
_pendingTransactions[transaction] = completer;
100+
101+
sink!.add(stringify(data));
102+
103+
// Optionally add a timeout
104+
return completer.future.timeout(Duration(seconds: 10), onTimeout: () {
105+
_pendingTransactions.remove(transaction);
106+
throw TimeoutException('Timed out waiting for transaction $transaction');
107+
});
96108
}
97109

98110
@override
99111
Future<dynamic> getInfo() async {
100112
if (!isConnected) {
101113
connect();
102114
}
103-
Map payload = {};
115+
Map<String, dynamic> payload = {};
104116
String transaction = getUuid().v4();
105117
payload['transaction'] = transaction;
106118
payload['janus'] = 'info';
107-
sink!.add(stringify(payload));
108-
return parse(await stream.firstWhere((element) => (parse(element)['transaction'] == payload['transaction']), orElse: () => {}));
119+
return send(payload);
109120
}
110121

111122
/// this method is internally called by plugin to establish connection with provided websocket uri.
@@ -121,5 +132,13 @@ class WebSocketJanusTransport extends JanusTransport {
121132
}
122133
sink = channel!.sink;
123134
stream = channel!.stream.asBroadcastStream();
135+
stream.listen((event) {
136+
final msg = parse(event);
137+
final transaction = msg['transaction'];
138+
if (transaction != null && _pendingTransactions.containsKey(transaction)) {
139+
_pendingTransactions[transaction]!.complete(msg);
140+
_pendingTransactions.remove(transaction);
141+
}
142+
});
124143
}
125144
}

pubspec.lock

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,18 @@ packages:
55
dependency: transitive
66
description:
77
name: _fe_analyzer_shared
8-
sha256: dc27559385e905ad30838356c5f5d574014ba39872d732111cd07ac0beff4c57
8+
sha256: e55636ed79578b9abca5fecf9437947798f5ef7456308b5cb85720b793eac92f
99
url: "https://pub.dev"
1010
source: hosted
11-
version: "80.0.0"
11+
version: "82.0.0"
1212
analyzer:
1313
dependency: transitive
1414
description:
1515
name: analyzer
16-
sha256: "192d1c5b944e7e53b24b5586db760db934b177d4147c42fbca8c8c5f1eb8d11e"
16+
sha256: "904ae5bb474d32c38fb9482e2d925d5454cda04ddd0e55d2e6826bc72f6ba8c0"
1717
url: "https://pub.dev"
1818
source: hosted
19-
version: "7.3.0"
19+
version: "7.4.5"
2020
args:
2121
dependency: transitive
2222
description:
@@ -101,10 +101,10 @@ packages:
101101
dependency: "direct main"
102102
description:
103103
name: dartdoc
104-
sha256: eb152ab07c585adb11cc24b7b93280a02f6ac5ff724cca4e6cabb24e8be88c82
104+
sha256: f978526530e42dbb831295af743c057d94533e89c27ce1f4023b252f3d85b8be
105105
url: "https://pub.dev"
106106
source: hosted
107-
version: "8.3.3"
107+
version: "8.3.4"
108108
fake_async:
109109
dependency: transitive
110110
description:
@@ -156,10 +156,10 @@ packages:
156156
dependency: "direct main"
157157
description:
158158
name: flutter_webrtc
159-
sha256: e84ca404ef4b0d07a0fcd676b15814fabd5bc08e8d4b8dd8b634f76beab1bb50
159+
sha256: dd47ca103b5b6217771e6277882674276d9621bbf9eb23da3c03898b507844e3
160160
url: "https://pub.dev"
161161
source: hosted
162-
version: "0.14.0"
162+
version: "0.14.1"
163163
glob:
164164
dependency: transitive
165165
description:
@@ -180,10 +180,10 @@ packages:
180180
dependency: "direct main"
181181
description:
182182
name: http
183-
sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f
183+
sha256: "2c11f3f94c687ee9bad77c171151672986360b2b001d109814ee7140b2cf261b"
184184
url: "https://pub.dev"
185185
source: hosted
186-
version: "1.3.0"
186+
version: "1.4.0"
187187
http_parser:
188188
dependency: transitive
189189
description:
@@ -481,10 +481,10 @@ packages:
481481
dependency: "direct main"
482482
description:
483483
name: web_socket_channel
484-
sha256: "0b8e2457400d8a859b7b2030786835a28a8e80836ef64402abef392ff4f1d0e5"
484+
sha256: d645757fb0f4773d602444000a8131ff5d48c9e47adfe9772652dd1a4f2d45c8
485485
url: "https://pub.dev"
486486
source: hosted
487-
version: "3.0.2"
487+
version: "3.0.3"
488488
webrtc_interface:
489489
dependency: transitive
490490
description:

pubspec.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: janus_client
22
description: A feature rich Janus Webrtc package
3-
version: 2.3.8
3+
version: 2.3.9
44
homepage: https://github.com/shivanshtalwar0/flutter_janus_client
55

66
environment:
@@ -16,10 +16,10 @@ dependencies:
1616
sdk: flutter
1717
flutter:
1818
sdk: flutter
19-
flutter_webrtc: ^0.14.0
19+
flutter_webrtc: ^0.14.1
2020
path_provider: ^2.1.5
21-
http: ^1.3.0
22-
web_socket_channel: ^3.0.2
21+
http: ^1.4.0
22+
web_socket_channel: ^3.0.3
2323
uuid: ^4.5.1
2424
logging: ^1.3.0
25-
dartdoc: ^8.3.3
25+
dartdoc: ^8.3.4

0 commit comments

Comments
 (0)