@xiboplayer/xmr 0.6.2 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +84 -21
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
# @xiboplayer/xmr
|
|
2
2
|
|
|
3
|
-
**XMR WebSocket client for real-time Xibo CMS commands.**
|
|
3
|
+
**XMR WebSocket client for real-time Xibo CMS push commands.**
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
7
|
Listens for push commands from the CMS over WebSocket with automatic reconnection:
|
|
8
8
|
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
- **
|
|
12
|
-
- **
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
- **13 command handlers** -- collectNow, screenshot, changeLayout, overlayLayout, revertToSchedule, purgeAll, commandAction, triggerWebhook, dataUpdate, rekeyAction, criteriaUpdate, currentGeoLocation, licenceCheck
|
|
10
|
+
- **Auto-reconnect** -- exponential backoff (5s base, up to 10 attempts), resumes on next collection cycle
|
|
11
|
+
- **Intentional shutdown** -- clean disconnect without triggering reconnection
|
|
12
|
+
- **Dual-path geo-location** -- CMS can push coordinates or request the player to report its position
|
|
13
|
+
|
|
14
|
+
## Architecture
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
CMS (Push) XmrWrapper PlayerCore
|
|
18
|
+
| | |
|
|
19
|
+
+--- WebSocket message ------> xmr.on('collectNow') -------> player.collect()
|
|
20
|
+
+--- WebSocket message ------> xmr.on('changeLayout') -----> player.changeLayout()
|
|
21
|
+
+--- WebSocket message ------> xmr.on('screenshot') -------> player.captureScreenshot()
|
|
22
|
+
+--- WebSocket message ------> xmr.on('purgeAll') ---------> player.purgeAll()
|
|
23
|
+
| | |
|
|
24
|
+
+--- disconnect -------------> scheduleReconnect() ---------> [5s, 10s, 15s, ...]
|
|
25
|
+
+--- reconnect --------------> xmr.on('connected') --------> updateStatus('XMR connected')
|
|
26
|
+
```
|
|
19
27
|
|
|
20
28
|
## Installation
|
|
21
29
|
|
|
@@ -26,22 +34,77 @@ npm install @xiboplayer/xmr
|
|
|
26
34
|
## Usage
|
|
27
35
|
|
|
28
36
|
```javascript
|
|
29
|
-
import {
|
|
37
|
+
import { XmrWrapper } from '@xiboplayer/xmr';
|
|
38
|
+
|
|
39
|
+
const xmr = new XmrWrapper(config, player);
|
|
30
40
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
channel: 'display-channel-key',
|
|
34
|
-
rsaKey: 'display-rsa-key',
|
|
35
|
-
});
|
|
41
|
+
// Start connection (from RegisterDisplay result)
|
|
42
|
+
const success = await xmr.start(xmrWebSocketAddress, xmrCmsKey);
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
if (success) {
|
|
45
|
+
console.log('XMR connected - real-time commands active');
|
|
46
|
+
} else {
|
|
47
|
+
console.log('XMR failed - falling back to polling mode');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Check status
|
|
51
|
+
xmr.isConnected(); // true/false
|
|
52
|
+
|
|
53
|
+
// Stop cleanly
|
|
54
|
+
await xmr.stop();
|
|
40
55
|
```
|
|
41
56
|
|
|
57
|
+
## Commands
|
|
58
|
+
|
|
59
|
+
| Command | Payload | Action |
|
|
60
|
+
|---------|---------|--------|
|
|
61
|
+
| `collectNow` | -- | Trigger immediate XMDS collection cycle |
|
|
62
|
+
| `screenShot` / `screenshot` | -- | Capture and upload display screenshot |
|
|
63
|
+
| `changeLayout` | `{ layoutId, duration?, downloadRequired?, changeMode? }` | Switch to specific layout |
|
|
64
|
+
| `overlayLayout` | `{ layoutId, duration?, downloadRequired? }` | Push overlay on top |
|
|
65
|
+
| `revertToSchedule` | -- | Return to normal scheduled content |
|
|
66
|
+
| `purgeAll` | -- | Clear all cached files and re-download |
|
|
67
|
+
| `commandAction` | `{ commandCode, commands? }` | Execute player command (HTTP only in browser) |
|
|
68
|
+
| `triggerWebhook` | `{ triggerCode }` | Fire a webhook trigger action |
|
|
69
|
+
| `dataUpdate` | -- | Force refresh data connectors |
|
|
70
|
+
| `rekeyAction` | -- | Rotate RSA key pair and re-register |
|
|
71
|
+
| `criteriaUpdate` | `data` | Update display criteria, trigger collection |
|
|
72
|
+
| `currentGeoLocation` | `{ latitude?, longitude? }` | Push coordinates or request location report |
|
|
73
|
+
| `licenceCheck` | -- | No-op for Linux clients |
|
|
74
|
+
|
|
75
|
+
## Reconnection
|
|
76
|
+
|
|
77
|
+
- **Base delay:** 5 seconds, linear increase (5s, 10s, 15s, ...)
|
|
78
|
+
- **Max attempts:** 10 per disconnect event
|
|
79
|
+
- **After max:** stops trying until next collection cycle calls `start()` again
|
|
80
|
+
- **Intentional stop:** `stop()` sets a flag that prevents reconnection on disconnect
|
|
81
|
+
|
|
82
|
+
## API Reference
|
|
83
|
+
|
|
84
|
+
### Constructor
|
|
85
|
+
|
|
86
|
+
```javascript
|
|
87
|
+
new XmrWrapper(config, player)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
| Parameter | Type | Description |
|
|
91
|
+
|-----------|------|-------------|
|
|
92
|
+
| `config` | Object | Player config with `hardwareKey`, `xmrChannel` |
|
|
93
|
+
| `player` | Object | PlayerCore instance with command methods |
|
|
94
|
+
|
|
95
|
+
### Methods
|
|
96
|
+
|
|
97
|
+
| Method | Returns | Description |
|
|
98
|
+
|--------|---------|-------------|
|
|
99
|
+
| `start(xmrUrl, cmsKey)` | `Promise<boolean>` | Connect to XMR WebSocket |
|
|
100
|
+
| `stop()` | `Promise<void>` | Disconnect cleanly (no reconnect) |
|
|
101
|
+
| `isConnected()` | `boolean` | Check connection status |
|
|
102
|
+
| `send(action, data)` | `Promise<boolean>` | Send message to CMS |
|
|
103
|
+
|
|
42
104
|
## Dependencies
|
|
43
105
|
|
|
44
|
-
- `@
|
|
106
|
+
- `@xibosignage/xibo-communication-framework` -- XMR protocol implementation
|
|
107
|
+
- `@xiboplayer/utils` -- logger
|
|
45
108
|
|
|
46
109
|
---
|
|
47
110
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiboplayer/xmr",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "XMR WebSocket client for real-time Xibo CMS commands",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@xibosignage/xibo-communication-framework": "^0.0.6",
|
|
13
|
-
"@xiboplayer/utils": "0.6.
|
|
13
|
+
"@xiboplayer/utils": "0.6.4"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"vitest": "^2.0.0"
|