diff --git a/README.md b/README.md index 1908334..aa1888f 100644 --- a/README.md +++ b/README.md @@ -26,13 +26,23 @@ naf-janus-adapter should support anything that supports recent WebRTC standards ``` +Default serverURL is `/janus` which is converted to `'wss://' + location.host + '/janus'`. +You can also specify a full url if the server is not the same: + +```html + +``` + Compared to other adapters like easyrtc, the janus adapter has a specific API, you need to call `NAF.connection.adapter.setClientId` and `NAF.connection.adapter.setLocalMediaStream`, see the [Audio example](examples/index.html) @@ -88,9 +98,6 @@ scene.addEventListener('adapter-ready', ({ detail: adapter }) => { - Build: `npm run build` - Release: `npm run release` -For development on the same LAN with `npm start` and if you run the janus docker image locally, you can use the config -`serverURL: wss://192.168.1.15:8080/janus;` (change the ip by yours of course). - ## Janus SFU deployment - [How to deploy janus with the janus sfu plugin on Ubuntu 20.04](docs/janus-deployment.md) diff --git a/examples/audio-with-camera.html b/examples/audio-with-camera.html index 681b9cc..e5d7a66 100644 --- a/examples/audio-with-camera.html +++ b/examples/audio-with-camera.html @@ -62,7 +62,6 @@ debug: false; adapter: janus; connectOnLoad: true; - serverURL: wss://preprod-janus.example.com/janus; " renderer="physicallyCorrectLights: true;" > diff --git a/examples/index.html b/examples/index.html index 50cfb5f..f413fbf 100644 --- a/examples/index.html +++ b/examples/index.html @@ -59,7 +59,7 @@ For development, networked-scene is configured with: adapter: janus - serverURL: wss://192.168.1.15:8080/janus; + serverURL: /janus; Run janus container locally: @@ -67,9 +67,9 @@ docker compose up cd naf-janus-adapter - npm start # to have https proxy on 8080 to janus http://127.0.0.1:8188/janus + npm start # to serve the examples and proxy /janus to http://127.0.0.1:8188/janus - go to https://192.168.1.15:8080 + go to https://localhost:8080 --> diff --git a/src/index.js b/src/index.js index 97d5b65..c4fddfc 100644 --- a/src/index.js +++ b/src/index.js @@ -193,6 +193,16 @@ class JanusAdapter { } connect() { + if (this.serverUrl === '/') { + this.serverUrl = '/janus'; + } + if (this.serverUrl === '/janus') { + if (location.protocol === 'https:') { + this.serverUrl = 'wss://' + location.host + '/janus'; + } else { + this.serverUrl = 'ws://' + location.host + '/janus'; + } + } debug(`connecting to ${this.serverUrl}`); const websocketConnection = new Promise((resolve, reject) => {