Endpoint class abstract

The Endpoint is an entrypoint to the Server. To add a custom Endpoint to a Server, create a subclass and place it in the endpoints directory. Code will generated that builds the corresponding client library. To add methods that can be accessed from the client, make sure that the first argument of the method is a Session parameter.

Constructors

Endpoint()

Properties

hashCode int
The hash code for this object.
no setterinherited
logSessions bool
States if Sessions should be logged for this endpoint. Defaults to true, override to change.
no setter
moduleName String?
The name of the current module, or null for the main server.
no setter
name String
The name of this Endpoint. It will be automatically generated from the name of the class (excluding any Endpoint suffix).
no setter
pod Serverpod
The ServerPod this Endpoint is running on.
no setter
requiredScopes Set<Scope>
List of Scopes that are required to access this Endpoint. Override this getter to setup custom requirements.
no setter
requireLogin bool
States if the Endpoint only should accept users that are authenticated. Default value is false, override to change.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sendByteDataAsRaw bool
If true, returned ByteData from methods will be sent sent to the client as raw data without any formatting. One use case is to return data through a non-api call. Defaults to false, override to change. If used, the endpoint method is responsible for correctly setting the contentType of the http response (defaults to text/plain).
no setter
server Server
The Server this Endpoint is running on.
no setter

Methods

getUserObject(Session session) → dynamic
Retrieves a custom object associated with this Endpoint and Session.
handleStreamMessage(StreamingSession session, SerializableModel message) Future<void>
Invoked when a message is sent to this endpoint from the client. Override this method to create your own custom StreamingEndpoint.
initialize(Server server, String name, String? moduleName) → void
Initializes the endpoint with the current Server. Typically, this is done from generated code.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sendStreamMessage(StreamingSession session, SerializableModel message) Future<void>
Sends an event to the client represented by the Session object.
setUserObject(Session session, dynamic userObject) → void
Associate a custom object with this Endpoint and Session.
streamClosed(StreamingSession session) Future<void>
Called when a stream was closed.
streamOpened(StreamingSession session) Future<void>
Override this method to setup a new stream when a client connects to the server.
toString() String
A string representation of this object.
inherited

Operators

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