MethodCallSession class
When a call is made to the Server a MethodCallSession object is created. It contains all data associated with the current connection and provides easy access to the database.
Constructors
-
MethodCallSession.new({required Server server, required Uri uri, required String body, required String path, required Request request, required String endpoint, required String method, required Map<
String, dynamic> queryParameters, required String? authenticationKey, bool enableLogging = true, String? remoteInfo}) - Creates a new Session for a method call to an endpoint.
Properties
-
authenticated
→ Future<
AuthenticationInfo?> -
The authentication information for the session.
This will be null if the session is not authenticated.
no setterinherited
- authenticationKey → String?
-
The authentication key used to authenticate the session.
no setterinherited
- body → String
-
The body of the server call.
final
- caches → Caches
-
Provides access to all caches used by the server.
no setterinherited
- db → Database
-
Access to the database.
no setterinherited
- 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
- endpoint → String
-
Endpoint that triggered this session.
finalinherited
- endpointName → String
-
The name of the endpoint that is being called.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
-
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
- method → String
-
The name of the method that is being called.
no setteroverride
- methodName → String
-
The name of the method that is being called.
no setter
-
passwords
→ Map<
String, String> -
Map of passwords loaded from config/passwords.yaml
no setterinherited
-
queryParameters
→ Map<
String, dynamic> -
Query parameters of the server call.
final
- remoteInfo → String?
-
Information identifying the remote client that triggered this session.
This is extracted from HTTP headers and may not be trustworthy.
finalinherited
- request → Request
-
The Request associated with the call.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- server → Server
-
The Server that created the session.
finalinherited
- serverpod → Serverpod
-
The Serverpod this session is running on.
no setterinherited
- sessionId → UuidValue
-
The id of the session.
finalinherited
- startTime → DateTime
-
The time the session object was created.
no setterinherited
- storage ↔ StorageAccess
-
Provides access to the cloud storages used by this Serverpod.
latefinalinherited
- transaction → Transaction?
-
Optional transaction to use for all database queries.
Only exists to support the serverpod_test package.
no setterinherited
- 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
Methods
-
addWillCloseListener(
WillCloseListener listener) → void -
Adds a listener that will be called when the session is about to close.
The listener should return a FutureOr that completes when the listener
is done.
inherited
-
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 anerror
/exception andstackTrace
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
-
removeWillCloseListener(
WillCloseListener listener) → void -
Removes a listener that will be called when the session is about to close.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
updateAuthenticated(
AuthenticationInfo? info) → void -
Updates the authentication information for the session.
This is typically done by the Server when the user is authenticated.
Using this method modifies the authenticated user for this session.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited