1313// limitations under the License.
1414
1515import '../core/room.dart' ;
16+ import '../e2ee/options.dart' ;
17+ import '../options.dart' ;
1618
1719/// Options for creating a [Session] .
1820class SessionOptions {
1921 /// The underlying [Room] used by the session.
22+ ///
23+ /// If neither [room] nor [encryption] is provided, a default [Room] is
24+ /// created. Passing both throws [ArgumentError] — configure E2EE on the
25+ /// [Room] directly if you need a custom [Room] with encryption.
2026 final Room room;
2127
2228 /// Whether to enable audio pre-connect with [PreConnectAudioBuffer] .
@@ -30,11 +36,33 @@ class SessionOptions {
3036 /// to a failed state.
3137 final Duration agentConnectTimeout;
3238
39+ /// Creates [SessionOptions] .
40+ ///
41+ /// Pass [encryption] to configure end-to-end encryption on the internally
42+ /// created [Room] . Use [E2EEOptions.sharedKey] for the common shared-key
43+ /// case. For advanced setups (custom [RoomOptions] , per-participant keys),
44+ /// build a [Room] yourself and pass it via [room] instead.
45+ ///
46+ /// Passing both [room] and [encryption] throws [ArgumentError] .
3347 SessionOptions ({
3448 Room ? room,
49+ E2EEOptions ? encryption,
3550 this .preConnectAudio = true ,
3651 this .agentConnectTimeout = const Duration (seconds: 20 ),
37- }) : room = room ?? Room ();
52+ }) : room = _buildRoom (room, encryption);
53+
54+ static Room _buildRoom (Room ? room, E2EEOptions ? encryption) {
55+ if (room != null && encryption != null ) {
56+ throw ArgumentError (
57+ 'SessionOptions: pass either `room` or `encryption`, not both. '
58+ 'To use encryption with a custom Room, configure E2EE on the Room directly.' ,
59+ );
60+ }
61+ if (encryption != null ) {
62+ return Room (roomOptions: RoomOptions (encryption: encryption));
63+ }
64+ return room ?? Room ();
65+ }
3866
3967 SessionOptions copyWith ({
4068 Room ? room,
0 commit comments