-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.lore
More file actions
42 lines (25 loc) · 2.42 KB
/
.lore
File metadata and controls
42 lines (25 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
-- pitfalls --
when attaching to an express/http server, you MUST call httpServer.listen() BEFORE mesh.ready(). ready() waits for the "listening" event - if you call ready() before listen(), it deadlocks forever.
do NOT implement your own ping/pong commands. mesh handles connection health automatically via built-in ping/pong at pingInterval (default 30s) and latency measurement at latencyInterval (default 5s). creating a custom ping command is redundant and shows a misunderstanding of the framework.
if using hooks mode for record persistence (persisting to your own DB schema), you do NOT need persistenceAdapter or persistenceOptions in server config. those are only for mesh's built-in adapter mode (JSON blob storage) and channel persistence.
ready() must be awaited before the server is operational. it waits for: http server listening, redis pub/sub subscription, persistence manager init, persisted record restoration.
-- client --
client reconnection options: shouldReconnect (bool), reconnectInterval (ms, default 2000), maxReconnectAttempts (default 5)
client events: connect, disconnect, reconnect, reconnectfailed, close, error, ping, latency (ms), message (raw)
client lifecycle methods: onConnect, onDisconnect, onReconnect, onReconnectFailed
-- integration --
integrates with @eaccess/auth via authenticateConnection option. use authenticateRequest(authConfig, req, sessionMiddleware) to validate sessions/remember tokens during websocket upgrade. return value becomes connection metadata. throw { code: 401, message } to reject.
role-based guards work by checking rolemask from connection metadata: (meta.rolemask & AuthRole.Admin) === AuthRole.Admin
-- broadcasting --
broadcastExclude(event, payload, connection) - broadcast to all except one connection
broadcastRoomExclude(room, event, payload, connections[]) - broadcast to room except specific connections
-- presence --
subscribePresence returns { success, present, states }
presence update types: join, leave, state
publishPresenceState(room, { state, expireAfter }) for ephemeral state (typing indicators, cursors)
clearPresenceState(room) to remove ephemeral state
trackPresence accepts guard and ttl options
-- collections --
exposeCollection(pattern, resolver) where resolver returns record IDs
client subscribeCollection returns { success, ids, records, version } with onUpdate and onDiff callbacks
onDiff provides { added: string[], removed: string[] } for membership changes