StreamingSession class

When a web socket connection is opened to the Server a StreamingSession object is created. It contains all data associated with the current connection and provides easy access to the database.

Inheritance

Constructors

StreamingSession({required Server server, required Uri uri, required HttpRequest httpRequest, required WebSocket webSocket, bool enableLogging = true})
Creates a new Session for the web socket stream.

Properties

auth UserAuthetication
Methods related to user authentication.
latefinalinherited
authenticationKey String?
The authentication key passed from the client.
no setterinherited
caches → Caches
Provides access to all caches used by the server.
no setterinherited
currentMessageId int
The id of the current incoming message being processed. Increments by 1 for each message passed to an endpoint for processing.
getter/setter pair
db ↔ DatabaseLegacy
Access to the database.
latefinalinherited
dbNext ↔ Database
Access to the database. Replaces db in the future.
latefinalinherited
duration Duration
Returns the duration this session has been open.
no setterinherited
enableLogging bool
True if logging is enabled for this session. Normally, logging should be enabled but it will be disabled for internal sessions used by Serverpod.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
httpRequest HttpRequest
The HttpRequest associated with the call.
final
isUserSignedIn Future<bool>
Returns true if the user is signed in.
no setterinherited
messages MessageCentralAccess
Access to the MessageCentral for passing real time messages between web socket streams and other listeners.
getter/setter pairinherited
passwords Map<String, String>
Map of passwords loaded from config/passwords.yaml
no setterinherited
queryParameters Map<String, String>
Query parameters of the server call.
latefinal
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
scopes Future<Set<Scope>?>
Returns the scopes associated with an authenticated user.
no setterinherited
server Server
The Server that created the session.
finalinherited
serverpod Serverpod
The Serverpod this session is running on.
no setterinherited
sessionLogId int?
Set if there is an open session log.
getter/setter pair
sessionLogs ↔ SessionLogEntryCache
Log messages saved during the session.
latefinalinherited
startTime DateTime
The time the session object was created.
no setterinherited
storage StorageAccess
Provides access to the cloud storages used by this Serverpod.
latefinalinherited
uri Uri
The uri that was used to call the server.
final
userObject ↔ dynamic
An custom object associated with this Session. This is especially useful for keeping track of the state in a StreamingEndpoint.
getter/setter pairinherited
webSocket WebSocket
The underlying web socket that handles communication with the server.
final

Methods

close({dynamic error, StackTrace? stackTrace}) Future<int?>
Closes the session. This method should only be called if you have manually created a the Session e.g. by calling createSession on Serverpod. Closing the session finalizes and writes logs to the database. After a session has been closed, you should not call any more methods on it. Optionally pass in an error/exception and stackTrace if the session ended with an error and it should be written to the logs. Returns the session id, if the session has been logged to the database.
inherited
log(String message, {LogLevel? level, dynamic exception, StackTrace? stackTrace}) → void
Logs a message. Default LogLevel is LogLevel.info. The log is written to the database when the session is closed.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
updateAuthenticationKey(String? authenticationKey) → void
Updates the authentication key for the streaming session.

Operators

operator ==(Object other) bool
The equality operator.
inherited