@xibosignage/xibo-communication-framework 0.0.2 → 0.0.3
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 +49 -0
- package/dist/xibo-communication-framework.cjs.js +8136 -7
- package/dist/xibo-communication-framework.cjs.js.map +1 -1
- package/dist/xibo-communication-framework.esm.js +8131 -2
- package/dist/xibo-communication-framework.esm.js.map +1 -1
- package/dist/xibo-communication-framework.js +8138 -7
- package/dist/xibo-communication-framework.min.js +2 -2
- package/dist/xibo-communication-framework.min.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1 +1,50 @@
|
|
|
1
1
|
# Xibo Communication Framework
|
|
2
|
+
|
|
3
|
+
A library written for web based players that will contain communication between the player and the CMS.
|
|
4
|
+
|
|
5
|
+
## Modules
|
|
6
|
+
|
|
7
|
+
* XMR - Basic implementation
|
|
8
|
+
* XMDS - To follow
|
|
9
|
+
|
|
10
|
+
### XMR
|
|
11
|
+
|
|
12
|
+
Start using XMR from this library by installing it through npm to our web based player (e.g. ChromeOS Player)
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
npm install @xibosignage/xibo-communication-framework
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Once the package is installed, we can import the XMR object from where we want to initialize it in our player.
|
|
19
|
+
|
|
20
|
+
```typescript
|
|
21
|
+
import {Xmr} from '@xibosignage/xibo-communication-framework';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
We can then create an instance of XMR object to manage the XMR state.
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
let xmr = new Xmr(config.xmrChannel || ‘unknown’);
|
|
28
|
+
|
|
29
|
+
// Initialize XMR
|
|
30
|
+
await xmr.init();
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`config.xmrChannel` is a randomly generated string for the XMR channel name.
|
|
34
|
+
|
|
35
|
+
Finally, we can start XMR when our display has been registered through the call on the XMDS register display. In the case of the ChromeOS player, we are doing the following after successful display registration.
|
|
36
|
+
|
|
37
|
+
Connected to a local development CMS the value for `xmrWebSocketAddress` would be [ws://localhost/xmr
|
|
38
|
+
](ws://localhost/xmr)
|
|
39
|
+
```typescript
|
|
40
|
+
// Web Sockets are only supported by the CMS if the XMDS version is 7, otherwise ZeroMQ web sockets should be used.
|
|
41
|
+
// Use ws not http
|
|
42
|
+
const protocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
43
|
+
|
|
44
|
+
// If the CMS has sent an alternative WS address, use that instead.
|
|
45
|
+
let xmrWebSocketAddress = config.getSetting(
|
|
46
|
+
'xmrWebSocketAddress',
|
|
47
|
+
cmsUrl.replace(window.location.protocol, protocol) + '/xmr'
|
|
48
|
+
);
|
|
49
|
+
xmr.start(xmrWebSocketAddress, config.getSetting('xmrCmsKey', 'n/a'));
|
|
50
|
+
```
|