@@ -102,6 +102,10 @@ In browser environment implement the websocket client: **index.html**
102102
103103## Documentation
104104
105+ ### Architecture Overview
106+
107+ ![ WebSocket Overview] ( ./docs/assets/overview.png )
108+
105109### WebSocket Server
106110
107111The websocket server is exposed on ` cds ` object implementation-independent at ` cds.ws ` and implementation-specific at
@@ -154,8 +158,9 @@ are not exposed, as the service itself is not marked as websocket protocol.
154158### Server Socket
155159
156160Each CDS handler request context is extended to hold the current server ` socket ` instance of the event.
157- It can be accessed via ` req.context.socket ` or ` cds.context.socket ` .
158- Events can be directly emitted via the ` socket ` bypassing CDS runtime.
161+ It can be accessed via the service websocket facade via ` req.context.ws.service ` or ` cds.context.ws.service ` .
162+ In addition the native websocket server socket can be accessed via ` req.context.ws.socket ` or ` cds.context.ws.socket ` .
163+ Events can be directly emitted via the native ` socket ` , bypassing CDS runtime, if necessary.
159164
160165### Middlewares
161166
@@ -258,10 +263,22 @@ CRUD events that modify entities automatically emit another event after successf
258263- ` <entity>:delete => <entity>:deleted ` : Entity instance has been deleted
259264
260265Because of security concerns, it can be controlled which data of those events is broadcast,
261- via annotations ` @websocket.broadcast ` or ` @ws.broadcast ` .
262-
263- - Propagate only key (default): ` @websocket.broadcast = 'key' ` , ` @ws.broadcast = 'key' `
264- - Propagate complete entity data: ` @websocket.broadcast = 'data' ` , ` @ws.broadcast = 'data' `
266+ via annotations ` @websocket.broadcast ` or ` @ws.broadcast ` on entity level.
267+
268+ - Propagate only key via one of the following options (default, if no annotation is present):
269+ - ` @websocket.broadcast = 'key' `
270+ - ` @websocket.broadcast.content = 'key' `
271+ - ` @ws.broadcast = 'key' `
272+ - ` @ws.broadcast.content = 'key' `
273+ - Propagate complete entity data via one of the following options:
274+ - ` @websocket.broadcast = 'data' `
275+ - ` @websocket.broadcast.content = 'data' `
276+ - ` @ws.broadcast = 'data' `
277+ - ` @ws.broadcast.content = 'data' `
278+
279+ Per default, this event is broadcast to every connected socket, expect the socket, that was called with the CRUD event.
280+ To also include the triggering socket within the broadcast, this can be controlled via annotations
281+ ` @websocket.broadcast.all ` or ` @ws.broadcast.all ` on entity level.
265282
266283### Examples
267284
0 commit comments