openSession method
RealtimeSessionScope
openSession({
- Uri? uri,
- String? sessionId,
- Map<
String, String> ? headers, - RealtimeProtocolType protocolType = RealtimeProtocolType.webSocket,
override
Opens and returns a RealtimeSessionScope for tracking an active connection.
Implementation
@override
RealtimeSessionScope openSession({
Uri? uri,
String? sessionId,
Map<String, String>? headers,
RealtimeProtocolType protocolType = RealtimeProtocolType.webSocket,
}) {
session.markRealtimeActive();
final effectiveId = sessionId ?? RequestId.generate();
final isCaptured = shouldCapture(uri);
if (uri != null && isCaptured) {
guardCapture(() {
session.recordRealtimeConnection(
id: effectiveId,
url: uri.toString(),
headers: headers ?? const {},
isPreValidated: true,
protocolType: protocolType,
);
});
}
final scope = RealtimeSessionScope(
collector: this,
sessionId: effectiveId,
uri: uri,
protocolType: protocolType,
shouldCapture: isCaptured,
);
_activeScopes[effectiveId] = scope;
return scope;
}