Skip to content

Commit

Permalink
Add shutdown function
Browse files Browse the repository at this point in the history
  • Loading branch information
njooma committed Aug 26, 2024
1 parent 3bc29c7 commit 993e9d9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
16 changes: 0 additions & 16 deletions lib/src/rpc/dial.dart
Original file line number Diff line number Diff line change
Expand Up @@ -612,19 +612,3 @@ _HostAndPort _hostAndPort(String address, bool insecure) {
}
return _HostAndPort(host, port);
}

/// A channel that adds session data (if required) to gRPC metadata for every call
class ClientChannelWithSessions extends GrpcOrGrpcWebClientChannel {
final String Function() _sessionId;

ClientChannelWithSessions.toSingleEndpoint(this._sessionId, {required super.host, required super.port, required super.transportSecure})
: super.toSingleEndpoint();

@override
ClientCall<Q, R> createCall<Q, R>(ClientMethod<Q, R> method, Stream<Q> requests, CallOptions options) {
if (!SessionsClient.unallowedMethods.contains(method.path)) {
options = options.mergedWith(CallOptions(metadata: {SessionsClient.sessionMetadataKey: _sessionId()}));
}
return super.createCall(method, requests, options);
}
}
7 changes: 7 additions & 0 deletions lib/src/rpc/web_rtc/web_rtc_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ class WebRtcClientChannel extends ClientChannelBase {
options = options.mergedWith(CallOptions(metadata: {'viam_client': getVersionMetadata()}));
return super.createCall(method, requests, options);
}

@override
Future<void> shutdown() async {
await rtcPeerConnection.close();
await dataChannel.close();
return super.shutdown();
}
}

0 comments on commit 993e9d9

Please sign in to comment.