Retrieving Single Active Sessions
Retrieves a single active sessions that have not completed its lifecyle (i.e. removed or cleared)
GET /v1/sessions?number=
Retrieves a single active session.
CoAP Options
Option | Description | Value | Required |
---|---|---|---|
URI-Path | Resource segment #1 | v1 | Yes |
URI-Path | Resource segment #2 | sessions | Yes |
URI-Query | Query option | number | Yes |
Response Properties
Sessions
To keep consistent with retrieval, a single session will be included in an array.
Property | Description | Type |
---|---|---|
id | Unique sequential number for each session that is created. | number |
uuid | UUID v4 that is generated for each session. | number |
number | Pager number the session is bound to. | number |
partySize | The size of the party for a session. | number |
goalInSeconds | The target goal in seconds that was assigned to the session. | number |
created | Timestamp of when the session is created. | string (ISO8601) |
started | Timestamp of when the session is started. Will be the same as started | string (ISO8601) |
notified | Timestamp when the session is paged. | string (ISO8601) |
cleared | Timestamp when the session is cleared. (Will only appear for notifications) | string (ISO8601) |
label | Assigned label to a session | string | null |
state | The state of a session. | string (enum) values: started paged * cleared |
Example Response
{
"responseTypes": [
"sessions"
],
"globalSessionSequence": 116,
"timestamp": "2018-03-15T11:50:27",
"deviceName": "T7470",
"firmwareVersion": "8.4.100.43",
"sessions": [
{
"id": 18,
"sessionSequence": 65535,
"uuid": "b4366f13-193f-4c93-bd6b-8f4d05a6ce37",
"number": 11,
"partySize": 1,
"goalInSeconds": 300,
"created": "2018-03-15T08:44:39",
"started": "2018-03-15T08:44:39",
"notified": "2018-03-15T08:49:39",
"label": null,
"state": "paged"
}
]
}
Example Code Request
// Using node-coap (yarn add coap, npm install coap): https://github.com/mcollina/node-coap
const coap = require('coap');
// Retrieving session with number 23
let req = coap.request({
host: '10.0.1.32',
port: 5683,
pathname: '/v1/sessions',
query: 'number=23',
method: 'GET'
});
req.on('response', res => {
let json = JSON.parse(res.payload.toString('utf-8'));
if (res.code[0] === '2') { // Success
// Will return array of sessions for consistency with /v1/sessions,
// so first index should be retrieved.
console.log(json.sessions[0]);
} else if (res.code === '4.04') {
// ~404 Not Found.
console.log("Session does not exist.");
} else {
// Some other error.
console.error(json);
}
});
// Send request
req.end();
Updated over 6 years ago