├── README.md ├── autorun.brs ├── index.html └── server ├── package.json └── server.js /README.md: -------------------------------------------------------------------------------- 1 | # websocket-test 2 | A simple example of how to use WebSockets with BrightSign 3 | 4 | This application runs a node.js server on the BrightSign, and uses a local websocket server. 5 | 6 | ## To run it: 7 | 8 | ### Run the server. For example, on your laptop: 9 | * Install NodeJS 10 | * In the "server" directory: 11 | * Run "npm install" 12 | * Run "node server.js" 13 | * Note the IP address of your laptop 14 | * Edit the following line in index.html to reflect the above IP address instead of 10.0.1.1: 15 | 16 | var wsUri = "wss://10.0.1.1:81/"; 17 | 18 | ### Configure your BrightSign player: 19 | * Put the files "autorun.brs" and "index.html" on an SD card 20 | * Connect the BrightSign player to the internet, and power it up 21 | * You should see "RESPONSE: Hi, you sent me WebSocket rocks" on the connected display. 22 | -------------------------------------------------------------------------------- /autorun.brs: -------------------------------------------------------------------------------- 1 | url$ = "file:///sd:/index.html" 2 | 3 | r=CreateObject("roRectangle", 0,0,1920,1080) 4 | is = { 5 | port: 2999 6 | } 7 | config = { 8 | nodejs_enabled: true 9 | inspector_server: is 10 | brightsign_js_objects_enabled: true 11 | hwz_default: "on" 12 | url: url$ 13 | } 14 | h=CreateObject("roHtmlWidget", r, config) 15 | p = CreateObject("roMessagePort") 16 | h.SetPort(p) 17 | h.Show() 18 | while true 19 | msg = wait(100, p) 20 | end while 21 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | WebSocket Test 5 | 64 | 65 | 66 |

WebSocket Test

67 | 68 |
69 | 70 | 71 | -------------------------------------------------------------------------------- /server/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "server", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "server.js", 6 | "scripts": { 7 | "start": "node server.js" 8 | }, 9 | "keywords": [], 10 | "author": "support@brightsign.biz (http://www.brightsign.biz/)", 11 | "license": "MIT", 12 | "dependencies": { 13 | "ws": "8.3.0" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /server/server.js: -------------------------------------------------------------------------------- 1 | // Basic Websocket (ws) echo server 2 | // Source: https://stackoverflow.com/a/64622710/570529 3 | const WebSocket = require('ws'); 4 | 5 | const ws_server = new WebSocket.Server({ port: 81 }); 6 | 7 | ws_server.on('connection', function connection(ws) { 8 | console.log("A client connected"); 9 | ws.on('message', function incoming(message) { 10 | ws.send('Hi, you sent me ' + message); 11 | }); 12 | }); 13 | 14 | --------------------------------------------------------------------------------