You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+37-7
Original file line number
Diff line number
Diff line change
@@ -265,14 +265,14 @@ In case of execution errors, the event broadcast is retried automatically, while
265
265
266
266
Events are broadcast to all websocket clients, including clients established in context of current event context user.
267
267
To influence event broadcasting based on current context user, the annotation `@websocket.user` or `@ws.user` is available on
268
-
event type level and entity type element level (alternatives include `@websocket.broadcast.user` or `@ws.broadcast.user`):
268
+
event type level and event type element level (alternatives include `@websocket.broadcast.user` or `@ws.broadcast.user`):
269
269
270
270
Valid annotation values are:
271
271
272
-
-**Entity type level**:
272
+
-**Event type level**:
273
273
-`'excludeCurrent'`: Current event context user is statically excluded everytime during broadcasting to websocket clients.
274
274
All websocket clients established in context to that user are not respected during event broadcast.
275
-
-**Entity type element level**:
275
+
-**Event type element level**:
276
276
-`'excludeCurrent'`: Current event context user is dynamically excluded during broadcasting to websocket clients,
277
277
based on the value of the annotated event type element.
278
278
If truthy, all websocket clients established in context to that user are not respected during event broadcast.
@@ -282,7 +282,8 @@ Valid annotation values are:
282
282
It is possible to broadcast events to a subset of clients. By entering or exiting contexts, the server can be instructed to
283
283
determined based on the event type, to which subset of clients the event shall be emitted. To specify which data parts of the
284
284
event are leveraged for setting up the context, the annotation `@websocket.context` or `@ws.context` is available on
285
-
event type element level (alternatives include `@websocket.broadcast.context` or `@ws.broadcast.context`):
285
+
event type element level (alternatives include `@websocket.broadcast.context` or `@ws.broadcast.context`). For static contexts
286
+
the annotation can also be used on event type level, providing a static event context string.
286
287
287
288
```cds
288
289
event received {
@@ -357,20 +358,49 @@ over remote distribution via Redis.
357
358
358
359
For Socket.IO (`kind: socket.io`) contexts are implemented leveraging [Socket.IO rooms](https://socket.io/docs/v4/rooms/).
359
360
361
+
### Event Client Identifier
362
+
363
+
Events are broadcast to all websocket clients, including clients that performed certain action. In some cases, the
364
+
websocket client shall not be informed about the event, that was triggered by the same client (maybe via a different channel, e.g. OData).
365
+
Therefore, websocket clients can be identified optionally by a unique identifier provided as URL parameter option `?id=<globally unique value>`.
366
+
The annotation `@websocket.identifier` or `@ws.identifier` is available on event type level and event type element level
367
+
to influence event broadcasting based websocket client identifier (alternatives include `@websocket.broadcast.identifier` or `@ws.broadcast.identifier`):
368
+
369
+
Valid annotation values are:
370
+
371
+
-**Event type level**:
372
+
- Provide a static unique identifier to exclude the client from event broadcasting
373
+
-**Event type element level**:
374
+
- Value from event data for the annotated element is used as unique identifier to exclude the websocket client from event broadcasting
375
+
- First annotated element with an defined event data value is taken
376
+
377
+
The unique identifier can be provided for a websocket client as follows:
378
+
379
+
-WS Standard:
380
+
```js
381
+
socket = new WebSocket("ws://localhost:4004/ws/chat?id=1234");
0 commit comments