Debian Codegraph @

testing/web-platform/tests/tools/wave/docs/rest-api/devices-api/register.md

raw
1 # `register event listener` - [Devices API](../README.md#devices-api)
2
3 The `register event listener` method of the devices API notifies a registered
4 listener upon device specific events. It uses HTTP long polling in send the
5 event to this listener in real time, so upon receiving an event, the
6 connection has to be reestablished by the client to receive further events.
7
8 ## HTTP Request
9
10 `GET /api/devices/<device_token>/events`
11
12 ## Query Parameters
13
14 | Parameter | Desciption | Example |
15 | ---------------- | ---------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
16 | `device_token` | The token of the device which performed the request. (Optional) Lets the server know the registered device is still active. | `device_token=7dafeec0-c351-11e9-84c5-3d1ede2e7d2e` |
17
18 ## Response Payload
19
20 ```json
21 {
22 "type": "<String>",
23 "data": "<Any>"
24 }
25 ```
26
27 - **type** defines what type of event has been triggered.
28 - **data** contains the event specific payload.
29
30 ## Event Types
31
32 ### Start session
33
34 See [device specific events](./event-types.md#device-specific)
35
36 ## Example
37
38 **Request:**
39
40 `GET /api/devices/1d9f5d30-830f-11ea-8dcb-0021ccd76152/events`
41
42 **Response:**
43
44 ```json
45 {
46 "type": "start_session",
47 "data": {
48 "session_token": "974c84e0-c35d-11e9-8f8d-47bb5bb0037d"
49 }
50 }
51 ```
52