Skip to content

Commit

Permalink
feat(config.js): add 'websocket' config option
Browse files Browse the repository at this point in the history
Config.js will allow to specify both BOSH and Websocket URLs. In such
case the web app will prefer Websocket over BOSH. The reason is that it
appears to be more stable and a bit fast on web, while on mobile
websocket is dropped fast(killed by the OS) on network changes.
  • Loading branch information
paweldomas committed Jan 24, 2020
1 parent 31d9fb1 commit b25db3c
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
3 changes: 3 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ var config = {
// BOSH URL. FIXME: use XEP-0156 to discover it.
bosh: '//jitsi-meet.example.com/http-bind',

// Websocket URL
// websocket: 'wss://jitsi-meet.example.com/xmpp-websocket',

// The name of client node advertised in XEP-0115 'c' stanza
clientNode: 'http://jitsi.org/jitsimeet',

Expand Down
10 changes: 9 additions & 1 deletion connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,15 @@ function connect(id, password, roomName) {
const connectionConfig = Object.assign({}, config);
const { issuer, jwt } = APP.store.getState()['features/base/jwt'];

connectionConfig.bosh += `?room=${roomName}`;
// Use Websocket URL for the web app if configured. Note that there is no 'isWeb' check, because there's assumption
// that this code executes only on web browsers/electron. This needs to be changed when mobile and web are unified.
let serviceUrl = connectionConfig.websocket || connectionConfig.bosh;

serviceUrl += `?room=${roomName}`;

// FIXME Remove deprecated 'bosh' option assignment at some point(LJM will be accepting only 'serviceUrl' option
// in future). It's included for the time being for Jitsi Meet and lib-jitsi-meet versions interoperability.
connectionConfig.serviceUrl = connectionConfig.bosh = serviceUrl;

const connection
= new JitsiMeetJS.JitsiConnection(
Expand Down
3 changes: 2 additions & 1 deletion react/features/base/connection/actions.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,8 @@ function _constructOptions(state) {

room && (bosh += `?room=${getBackendSafeRoomName(room)}`);

options.bosh = bosh;
// FIXME Remove deprecated 'bosh' option assignment at some point.
options.serviceUrl = options.bosh = bosh;
}

return options;
Expand Down

0 comments on commit b25db3c

Please sign in to comment.