openvibers/openvibe.connect Commits

The client goes to production when used as a module with no server (#3)

OP OpenVibers committed 11 days ago · bd94fc556f · 3 files, +10 −3

createClient() took its server only from the command line's defaults, so a script that required ov-connect.js and
passed no server tried to open "undefined" (found by the production proof, 11-02). It now defaults to
wss://connect.openvibe.website/tunnel like the command line. STATUS: deployed.

Changes

ddiff --git a/STATUS.json b/STATUS.json
iindex 66dafdd..a4d82f6 100644
---- a/STATUS.json
++++ b/STATUS.json
@@@ -35,7 +35,7 @@
],
"capabilitiesRegistered": false,
"serviceManifestRegistered": true,
-- "deployed": false,
++ "deployed": true,
"placeholderInSites": false,
"seed": "none",
"features": [],
ddiff --git a/public/ov-connect.js b/public/ov-connect.js
iindex 78fda84..72ebf97 100644
---- a/public/ov-connect.js
++++ b/public/ov-connect.js
@@@ -25,7 +25,7 @@ const HIGH_WATER = 4 * 1024 * 1024;
const KIND = { DATA: 1, END: 2 };
function parseArgs(argv) {
-- const o = { key: process.env.OV_CONNECT_KEY || '', port: 0, server: process.env.OV_CONNECT_SERVER || 'wss://connect.openvibe.website/tunnel', quiet: false };
++ const o = { key: process.env.OV_CONNECT_KEY || '', port: 0, server: process.env.OV_CONNECT_SERVER || DEFAULT_SERVER, quiet: false };
for (let i = 0; i < argv.length; i++) {
const a = argv[i];
if (a === '--key') o.key = argv[++i] || '';
@@@ -71,7 +71,10 @@ function main() {
/**
* The client itself (exported for tests): createClient({ key, port, server, quiet, log, localHost }) → { start, stop, onReady }
*/
++const DEFAULT_SERVER = 'wss://connect.openvibe.website/tunnel';
++
function createClient(opts) {
++ opts = { ...opts, server: opts.server || DEFAULT_SERVER };
const log = opts.log || ((line) => console.log(line));
const localHost = opts.localHost || 'localhost';
let ws = null;
@@@ -228,4 +231,4 @@ function createClient(opts) {
if (require.main === module) main();
--module.exports = { createClient, parseArgs, encode, VERSION };
++module.exports = { createClient, parseArgs, encode, VERSION, DEFAULT_SERVER };
ddiff --git a/test/rules.test.js b/test/rules.test.js
iindex 7a4a6b5..edfda8c 100644
---- a/test/rules.test.js
++++ b/test/rules.test.js
@@@ -75,6 +75,10 @@ const { createGate } = require('../server/edge/gate');
const { parseArgs } = require('../public/ov-connect');
assert.strictEqual(parseArgs(['--key', 'ovc_x', '8080']).port, 8080);
assert.strictEqual(parseArgs(['--key=ovc_y', '--port=9']).key, 'ovc_y');
++ // Used as a module (createClient) with no server, it still goes to production, not to "undefined".
++ const { DEFAULT_SERVER } = require('../public/ov-connect');
++ assert.strictEqual(DEFAULT_SERVER, 'wss://connect.openvibe.website/tunnel');
++ assert.strictEqual(parseArgs([]).server, DEFAULT_SERVER);
});
done();