Skip to content

Commit c4df9a6

Browse files
committed
Readme
1 parent b4a82e6 commit c4df9a6

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,38 @@ event received {
205205
}
206206
```
207207

208-
This sets up the event context based on the unique ID of the event data. The annotation can be used on multiple event
209-
data elements setting up different event contexts in parallel, if event shall be broadcast/emitted into multiple contexts at the same time.
208+
This sets up the event context based on the unique ID of the event data.
209+
210+
The annotation can be used on multiple event data elements setting up different event contexts in parallel,
211+
if event shall be broadcast/emitted into multiple contexts at the same time.
212+
213+
```cds
214+
event received {
215+
@websocket.context
216+
ID: UUID;
217+
@websocket.context
218+
name: String;
219+
text: String;
220+
}
221+
```
222+
223+
Event contexts can also be established via event type elements of `many` or `array of` type:
224+
225+
```cds
226+
event received {
227+
@websocket.context
228+
ID: many UUID;
229+
text: String;
230+
}
231+
```
232+
233+
This allows setting up an unspecified number of different event contexts in parallel during runtime.
234+
235+
Event contexts support all CDS/JS types. The serialization is performed as follows:
236+
237+
- `Date`: `context.toISOString()`
238+
- `Object`: `JSON.stringify(context)`
239+
- other: `String(context)`
210240

211241
To manage event contexts the following options exist:
212242

0 commit comments

Comments
 (0)