swamp library
Swamp Server Dart library
Classes
- AuthenticatedUser
- An authenticated Swamp user and the permissions granted by its source.
- AuthenticationPolicy
- Controls which operations require authentication.
- AuthenticationRequest
- The credentials and connection metadata passed to an AuthenticationSource.
- AuthenticationSource
- A provider capable of resolving connection credentials to a user.
- ConfigManager
- Manages the runtime configuration of the server.
-
RateLimiterPipe<
T> - RestApiAuthenticationSource
- Authentication source that validates credentials using a REST endpoint.
- RoomInfo
- Information about a room, including its configuration and state.
- RoomProgram
- RoomsProgram
- StaticAuthenticationSource
- Authentication source backed by an in-memory token map.
- StaticFileAuthenticationSource
- Authentication source backed by a JSON file.
- StopProgram
- SwampAuthentication
- Combines authentication sources with connection and creation policy.
- SwampAuthenticationManager
- Owns authentication state for active server connections.
- SwampConfig
-
SwampConfigCopyWith<
$R, $In extends SwampConfig, $Out> - SwampConfigMapper
- SwampRoom
- Represents a room/lobby in the Swamp server.
- SwampRoomManager
- Manages the lifecycle and operations of rooms on the server.
- SwampServer
- The main Swamp server class.
Enums
- AuthenticationAttemptResult
- The outcome of a protocol-level authentication attempt.
- CreationFailedReason
- JoinFailedReason
- KickReason
- SwampCommand
- Commands sent from the client to the server.
- SwampEvent
- Events sent from the server to the client.
Mixins
Extension Types
- RoomFlags
- Flags configuring the behavior of a room.
Extensions
-
SwampConfigValueCopy
on ObjectCopyWith<
$R, SwampConfig, $Out>
Constants
- kPageSize → const int
- kRoomIdLength → const int
- The length of a room ID in bytes.
- kSwampProtocolPrefix → const String
- Prefix used to build WebSocket subprotocol identifiers.
- kSwampProtocolVersion → const int
- The current Swamp protocol version.
-
kSwampSupportedProtocols
→ const List<
int> - All protocol versions the library understands.
Properties
Functions
-
decodeRoomCode(
String code) → Uint8List - Decodes a room code string into its byte array representation.
-
encodeRoomCode(
Uint8List data) → String - Encodes a room code (byte array) into a string representation.
-
generateRandomRoomId(
) → Uint8List - Generates a cryptographically secure random room ID.
-
parseSwampSubprotocol(
String subprotocol) → int? -
Parses a WebSocket subprotocol string (e.g.
swamp-1) and returns the protocol version number, ornullif the format is invalid. -
showPublicInfo(
SwampServer server, HttpRequest request) → void -
swampAuthenticationFromEnvironment(
Map< String, String> environment) → SwampAuthentication? - Creates authentication configuration from Swamp environment variables.
-
swampSubprotocol(
[int version = kSwampProtocolVersion]) → String -
Builds the WebSocket subprotocol string for a given
version.