Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/src/token_source/room_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@ class RoomAgentDispatch {
/// Metadata for the agent.
final String? metadata;

/// Optional deployment to target. Leave empty to target the production deployment.
final String? deployment;

const RoomAgentDispatch({
this.agentName,
this.metadata,
this.deployment,
});

factory RoomAgentDispatch.fromJson(Map<String, dynamic> json) => _$RoomAgentDispatchFromJson(json);
Expand Down
2 changes: 2 additions & 0 deletions lib/src/token_source/room_configuration.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions lib/src/token_source/token_source.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class TokenRequestOptions {
/// Metadata passed to the agent job.
final String? agentMetadata;

/// Optional deployment to target. Leave empty to target the production deployment.
final String? agentDeployment;

const TokenRequestOptions({
this.roomName,
this.participantName,
Expand All @@ -51,15 +54,16 @@ class TokenRequestOptions {
this.participantAttributes,
this.agentName,
this.agentMetadata,
this.agentDeployment,
});

factory TokenRequestOptions.fromJson(Map<String, dynamic> json) => _$TokenRequestOptionsFromJson(json);
Map<String, dynamic> toJson() => _$TokenRequestOptionsToJson(this);

/// Converts this options object to a wire-format request.
TokenSourceRequest toRequest() {
final List<RoomAgentDispatch>? agents = (agentName != null || agentMetadata != null)
? [RoomAgentDispatch(agentName: agentName, metadata: agentMetadata)]
final List<RoomAgentDispatch>? agents = (agentName != null || agentMetadata != null || agentDeployment != null)
? [RoomAgentDispatch(agentName: agentName, metadata: agentMetadata, deployment: agentDeployment)]
: null;

return TokenSourceRequest(
Expand All @@ -83,6 +87,7 @@ class TokenRequestOptions {
other.participantMetadata == participantMetadata &&
other.agentName == agentName &&
other.agentMetadata == agentMetadata &&
other.agentDeployment == agentDeployment &&
const MapEquality().equals(other.participantAttributes, participantAttributes);
}

Expand All @@ -95,6 +100,7 @@ class TokenRequestOptions {
participantMetadata,
agentName,
agentMetadata,
agentDeployment,
const MapEquality().hash(participantAttributes),
);
}
Expand Down
2 changes: 2 additions & 0 deletions lib/src/token_source/token_source.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading