Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
oklemenz2 committed Sep 24, 2024
1 parent 48373ab commit 8f3098d
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 662 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ It abstracts from the concrete websocket implementation by exposing the followin
- `context: Object`: CDS context object for the websocket server socket
- `on(event: String, callback: Function)`: Register websocket event
- `async emit(event: String, data: Object)`: Emit websocket event with data
- `async broadcast(event: String, data: Object, user: {include: String[], exclude: String[]}?, contexts: String[]?, identifier: {include: String[], exclude: String[]}?)`:
- `async broadcast(event: String, data: Object, user: {include: String[], exclude: String[]}?, context: : {include: String[], exclude: String[]}?, identifier: {include: String[], exclude: String[]}?)`:
Broadcast websocket event (except to sender) by optionally restrict to users, contexts or identifiers
- `async broadcastAll(event: String, data: Object, user: {include: String[], exclude: String[]}?, contexts: String[]?, identifier: {include: String[], exclude: String[]}?)`:
- `async broadcastAll(event: String, data: Object, user: {include: String[], exclude: String[]}?, context: : {include: String[], exclude: String[]}?, identifier: {include: String[], exclude: String[]}?)`:
Broadcast websocket event (including to sender) by optionally restrict to users, contexts or identifiers
- `async enter(context: String)`: Enter a context
- `async exit(context: String)`: Exit a context
Expand Down Expand Up @@ -267,6 +267,8 @@ const wsService = await cds.connect.to("WSService");
await wsService.emit("message", req.data);
```

`cds.conntect.to` can be used to connect to any WebSocket enabled service, to emit events to the WebSocket service.

### Transactional Safety

In most situations only websocket events shall be broadcast, in case the primary transaction succeeded.
Expand Down Expand Up @@ -460,8 +462,7 @@ Event is only published to all users listed in the event data of `users`.
### Event Contexts

It is possible to broadcast events to a subset of clients. By entering or exiting contexts, the server can be instructed
to
determined based on the event, to which subset of clients the event shall be emitted. To specify which data parts of the
to determine to which subset of clients the event shall be emitted, based on the event. To specify which data parts of the
event are leveraged for setting up the context, the annotation `@websocket.context` or `@ws.context` is available on
event element level (alternatives include `@websocket.broadcast.context` or `@ws.broadcast.context`). For static
contexts
Expand Down
Loading

0 comments on commit 8f3098d

Please sign in to comment.