diff --git a/.gitignore b/.gitignore index 8493824..b3b69ef 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ npm-debug.log tags cpplint.py generated +package-lock.json diff --git a/examples/html/client.html b/examples/html/client.html index 67219d6..8bfcb26 100644 --- a/examples/html/client.html +++ b/examples/html/client.html @@ -36,7 +36,12 @@ }); // Create a connection to the rosbridge WebSocket server. - ros.connect('ws://localhost:9090'); + if (window.location.protocol == "https:") { + var ws_scheme = "wss://"; + } else { + var ws_scheme = "ws://" + }; + ros.connect(ws_scheme + window.location.hostname + ':9090'); // Create a Service client with details of the service's name and service type. var addTwoInts = new ROSLIB.Service({ diff --git a/examples/html/publisher.html b/examples/html/publisher.html index d6d00da..e91611a 100644 --- a/examples/html/publisher.html +++ b/examples/html/publisher.html @@ -36,7 +36,12 @@ }); // Create a connection to the rosbridge WebSocket server. - ros.connect('ws://localhost:9090'); + if (window.location.protocol == "https:") { + var ws_scheme = "wss://"; + } else { + var ws_scheme = "ws://" + }; + ros.connect(ws_scheme + window.location.hostname + ':9090'); // Publish a Topic var example = new ROSLIB.Topic({ diff --git a/examples/html/service.html b/examples/html/service.html index 33fb41b..365d192 100644 --- a/examples/html/service.html +++ b/examples/html/service.html @@ -36,7 +36,12 @@ }); // Create a connection to the rosbridge WebSocket server. - ros.connect('ws://localhost:9090'); + if (window.location.protocol == "https:") { + var ws_scheme = "wss://"; + } else { + var ws_scheme = "ws://" + }; + ros.connect(ws_scheme + window.location.hostname + ':9090'); // Create a Service client with details of the service's name and service type. var addTwoInts = new ROSLIB.Service({ diff --git a/examples/index.js b/examples/index.js index 646a1bf..e857526 100644 --- a/examples/index.js +++ b/examples/index.js @@ -17,7 +17,7 @@ const express = require('express'); const app = express(); -app.use(express.static('.')); +app.use(express.static('html')); -app.listen(3000); -console.log('The web server started on http://localhost:3000'); +app.listen(3000, '0.0.0.0'); +console.log('The web server started on http://0.0.0.0:3000'); diff --git a/index.js b/index.js index 7f7cb86..48c2150 100644 --- a/index.js +++ b/index.js @@ -55,6 +55,8 @@ function createServer(options) { debug('Application will exit.'); shutDown(); }); + process.on('SIGINT', process.exit); + return rclnodejs.init() .then(() => { node = rclnodejs.createNode('ros2_web_bridge'); diff --git a/lib/bridge.js b/lib/bridge.js index c6f2d68..e2ae9c7 100644 --- a/lib/bridge.js +++ b/lib/bridge.js @@ -17,7 +17,7 @@ const ResourceProvider = require('./resource_provider.js'); const debug = require('debug')('ros2-web-bridge:Bridge'); const EventEmitter = require('events'); -const uuidv4 = require('uuid/v4'); +const { v4: uuidv4 } = require('uuid'); const {validator} = require('rclnodejs'); const STATUS_LEVELS = ['error', 'warning', 'info', 'none']; diff --git a/package.json b/package.json index 10428cb..e6a590c 100644 --- a/package.json +++ b/package.json @@ -33,18 +33,18 @@ ], "devDependencies": { "async": "^3.2.0", - "express": "^4.16.2", "eslint": "^6.8.0", + "express": "^4.17.1", "js-sha512": "^0.8.0", - "mocha": "^7.1.1", "jsdom": "^16.2.1", + "mocha": "^7.1.1", "puppeteer": "^2.1.1" }, "dependencies": { - "commander": "^5.0.0", - "debug": "^4.1.1", - "rclnodejs": "^0.x.1", - "uuid": "^7.0.2", - "ws": "^7.1.1" + "commander": "^6.2.1", + "debug": "^4.3.1", + "rclnodejs": "^0.17.0", + "uuid": "^8.3.2", + "ws": "^7.4.1" } }