FakeDomeServer class final

In-memory fake media server implementing contract API v1. See the library comment.

Constructors

FakeDomeServer({String name = 'Fake dome', Map<String, (String, String)> users = const {'admin' : ('admin', 'admin'), 'operator' : ('operator', 'operator'), 'root' : ('root', 'superadmin')}, bool allowAnonymousGuest = true, Duration accessTokenTtl = const Duration(minutes: 15), int heartbeatSec = 20})
Creates a fake with the given local users (username → (password, role)).

Properties

accessTokenTtl ↔ Duration
Lifetime of issued access tokens.
getter/setter pair
allowAnonymousGuest ↔ bool
Kiosk mode: requests without credentials get the guest scopes.
getter/setter pair
audioPresets → Map<String, Map<String, Object?>>
Installed audio presets (JSON, for assertions).
no setter
audioSessions → Map<String, Map<String, Object?>>
Audio sessions the fake knows (JSON, for assertions).
no setter
audioStepInterval ↔ Duration
How fast audio calibration jobs advance one step (sweep + capture per speaker, then solve).
getter/setter pair
autoApprovePairings ↔ bool
Pairings without an approved link code wait for an operator; with this flag they are approved at once.
getter/setter pair
baseUri ↔ Uri
Base URL this fake is reachable at (in-process: a placeholder; bound: the real address).
getter/setter pair
bus → FakeEventBus
The event bus (sessions, history).
final
clients → Map<String, Map<String, Object?>>
Registered client devices.
no setter
endpoint → FreedomeEndpoint
An endpoint value pointing at this fake.
no setter
graphql → FakeGraphql
The GraphQL executor (also used by the bound mode).
latefinal
hashCode → int
The hash code for this object.
no setterinherited
heartbeatSec ↔ int
welcome.heartbeatSec.
getter/setter pair
instanceId → String
instanceId (UUIDv7).
final
latency ↔ Duration
Artificial latency of every response.
getter/setter pair
name → String
Installation name (GET /info).
final
networkDown ↔ bool
When true every request / connection fails without a response (network down).
getter/setter pair
oscSent → List<(String?, String, List<Object?>)>
Messages accepted by sendOsc (target, address, args).
final
pendingPairingCodes → List<String>
Codes of pairings waiting for approval.
no setter
realtimeAvailable ↔ bool
When false, realtime connections are refused (REST-only server → client degraded).
getter/setter pair
requests → List<FreedomeRequest>
Every request received, in order (for assertions).
final
resolumeReachable ← bool
Whether the Resolume web server answers: when false, rest and ws go down and the gateway degraded, while osc stays up, as UDP has no acknowledgement.
no getter
resolumeRuntimeSettings ↔ bool
Whether patchGateway accepts config on the Resolume driver. The media server refuses it (422, pointer /config) until driver settings can change at run time.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
strictResponses ↔ bool
Throw a StateError when a response of the fake does not match the contract schema of its status (finds fake bugs in tests; off for apps that only want a stand-in).
getter/setter pair
transports → FreedomeTransportFactory
Transport factory for FreedomeClient(transports: …) (in-process REST + sockets).
no setter
validateRequests ↔ bool
Validate requests against the contract (parameters, content type, JSON body): 405 / 415 / 422 / 428 as the contract says. On by default.
getter/setter pair

Methods

acceptSocket(String path, MessageSocket server) → void
Opens the server side of a realtime connection at path (/api/v1/ws or /api/v1/graphql) on server.
addApiKey(String key, {String role = 'operator', String? name}) → void
Adds an API key with the scopes of role (token fdk_…).
addAsset(Uint8List bytes, {String name = 'asset.bin', String type = 'video', String? id, double? duration, List<String> tags = const []}) → String
Adds an asset with bytes (status ready); returns its id.
addAudioDevice(String id, {String kind = 'speaker', String venueId = 'default'}) → void
Adds an audio device (QRD, Patefon, speaker amp, microphone …) to venueId.
addCloudToken(String jwt, {String role = 'operator'}) → void
Accepts jwt at POST /auth/token-exchange as a cloud user with role.
addDevice(String id, {String variant = 'fd-vp-f-1', String address = '10.0.0.20:50063'}) → void
Adds a visual device agent (as discovered by the media server's device adapter).
addScenario(String id, {bool enabled = true, Map<String, Object?> paramsSchema = const {'type' : 'object'}}) → void
Installs a scenario plugin.
addShow(DomeManifest manifest) → String
Adds a show from a .dome manifest (kind show / bundle); returns its id.
addVenue(DomeManifest manifest, {Map<String, Uint8List> files = const {}, bool makeDefault = false}) → String
Adds (or replaces) the venue of manifest (kind venue / bundle) with its calibration files; the first venue added becomes default. Returns the venue id.
addVenuePackage(DomePackage pkg, {bool makeDefault = false}) → Future<String>
Adds the venue of a decoded .dome incl. its calibration sidecars.
advanceAudioSession(String sessionId, {double? position, String? status}) → void
Test hook: an audio session moves to position seconds (patch, as the server's ≤ 1 Hz position feed) and / or changes status (full state).
appPayloads(String app) → List<Map<String, Object?>>
Payloads published by app.
approvePairing(String code, {String role = 'operator'}) → bool
Approves the pending pairing showing code (operator action); returns false when none.
asset(String id) → Map<String, Object?>?
The asset record id.
assetBytes(String id) → Uint8List?
Stored bytes of asset id.
bumpApiMajor() → void
Announces API v2 only (client must report incompatible).
callOp(String op, Map<String, String> params, Object? body, String? ifMatch, String? token, String idempotencyKey) → Future<(int, Object?, String?)>
Executes call messages of realtime sessions through the same routes.
degradeEngine([String status = 'degraded']) → void
Visual engine reports degraded (or status); publishes engine.status.
deviceCode(String deviceId) → String?
The code a device shows after beginDevicePairing (what the operator reads off the device).
dispose() → Future<void>
Stops background timers (call at the end of tests that used realtime).
dropRealtime() → Future<void>
Drops every realtime connection (as a network glitch); clients reconnect and resume.
dropUploadAfter(int bytes) → void
The next tus PATCH that would take an upload past bytes stores the bytes and then fails without a response (connection killed mid-upload).
emitAudioLevels(Map<String, double> levels, {String venueId = 'default'}) → void
Test hook: one meter frame (audio.levels, {meter id: dBFS}).
expireTokens({bool refreshToo = false}) → void
Invalidates every access token (refreshToo: refresh tokens as well); open sessions are closed with 4401.
failNext(String operationId, {int status = 503, String code = 'engine-unavailable', String? detail, int times = 1}) → void
Makes the next times calls of operationId fail with status / code.
handle(FreedomeRequest r) → Future<FreedomeResponse>
Handles one REST request (what the in-process transport and the bound server call). Throws NetworkException while networkDown.
issuePairingCode() → String
Arms a one-time code (as a dome console showing a QR link would): the next pairing request is approved at once and receives this code.
log(String level, String message, {String target = 'fake'}) → void
Adds a log line (system/logs event).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
publishAnalysisFrame(AudioAnalysisFrame frame, {String venueId = 'default'}) → void
Publishes an analysis frame (audio.analysis).
publishOnset(AudioOnset onset, {String venueId = 'default'}) → void
Publishes a detected attack (audio.onset).
rateLimit(String operationId, {int times = 1, Duration retryAfter = const Duration(seconds: 1)}) → void
The next times calls of operationId answer 429 with Retry-After retryAfter.
restart() → Future<void>
Server restart: realtime closed with 1012, event sequence restarts (new epoch).
scopesOf(String? token) → Set<String>?
Scopes of a bearer token / API key (null = rejected); used by realtime sessions.
seedAudioReactive({String venueId = 'default'}) → void
Adds the resolume gateway, analysis inputs vocal and drums, scenes vocal-aura and percussion-wave and one Spout source to venue venueId.
sendClientCommand(String clientId, String command, [Object? args]) → void
Sends a client.command (vibrate, capture, …) to a registered client device.
seqGap() → void
Makes resuming impossible (ring buffer forgotten) and tells every session to resync.
setAudioDeviceOnline(String id, {bool online = true, String venueId = 'default'}) → void
Test hook: the media server sees audio device id come online / go offline (audioDevice.state patch).
setAudioReactiveStatus(String? status, {String venueId = 'default'}) → void
Forces the AudioReactive status (null = derived from enabled), as a stopped input would.
setTextureSource(TextureSource source, {String venueId = 'default'}) → void
Adds or replaces a texture source and publishes textureSource.state.
toString() → String
A string representation of this object.
inherited
venueBody([String? id]) → Map<String, Object?>?
The stored body of venue id (or the default venue).
venueFile(String venueId, String path) → Uint8List?
Stored calibration sidecar bytes of venue venueId at path.

Operators

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

Static Methods

bind({FakeDomeServer? server, int port = 0, String address = '127.0.0.1', bool mdns = false, String? log}) → Future<FakeDomeServerBinding>
Binds the fake to a TCP port (dart:io only): REST + plain WS + GraphQL (HTTP + WS) + socket.io /v1; with mdns it also answers mDNS queries for _freedome._tcp. Returns the bound server; close() it at the end.