From 182e1e0deb66ec121cb42d3424aea622b8d722b6 Mon Sep 17 00:00:00 2001 From: Alim TUNC Date: Wed, 5 Jul 2023 17:14:43 +0200 Subject: [PATCH] Connect meet low level to the jitsi provider --- core/modules/meet/client/meet-low-level.js | 112 +++++++++++---------- core/modules/meet/server/meet.js | 15 +++ 2 files changed, 75 insertions(+), 52 deletions(-) diff --git a/core/modules/meet/client/meet-low-level.js b/core/modules/meet/client/meet-low-level.js index b3e234a3..3c60c632 100644 --- a/core/modules/meet/client/meet-low-level.js +++ b/core/modules/meet/client/meet-low-level.js @@ -228,53 +228,59 @@ const onUserPropertyUpdated = async (e, template) => { ** LowMeetJs */ -const DOMAIN = '8x8.vc' -const getOptions = () => ({ - // Connection - hosts: { - domain: DOMAIN, - muc: `conference.${DOMAIN}`, - focus: `focus.${DOMAIN}`, - }, - serviceUrl: `wss://${DOMAIN}/xmpp-websocket?room=${meetLowLevel.roomName}`, - websocketKeepAliveUrl: `https://${DOMAIN}/_unlock?room=${meetLowLevel.roomName}`, +const getOptions = () => { + const serverURL = Meteor.settings.public.meet.serverURL + + if (!serverURL) return + const [domain, sub] = serverURL.split('/') + + return { + // Connection + hosts: { + domain: serverURL, + muc: `conference.${sub}.${domain}`, + focus: `focus.${domain}`, + }, + serviceUrl: `wss://${serverURL}/xmpp-websocket?room=${meetLowLevel.roomName}`, + websocketKeepAliveUrl: `https://${serverURL}/_unlock?room=${meetLowLevel.roomName}`, - // Enable Peer-to-Peer for 1-1 calls - p2p: { - enabled: false, - }, + // Enable Peer-to-Peer for 1-1 calls + p2p: { + enabled: false, + }, - // Video quality / constraints - constraints: { - video: { - height: { - ideal: 720, - max: 720, - min: 180, - }, - width: { - ideal: 1280, - max: 1280, - min: 320, + // Video quality / constraints + constraints: { + video: { + height: { + ideal: 720, + max: 720, + min: 180, + }, + width: { + ideal: 1280, + max: 1280, + min: 320, + }, }, }, - }, - channelLastN: 25, + channelLastN: 25, - // Logging - logging: { - // Default log level - defaultLogLevel: 'trace', + // Logging + logging: { + // Default log level + defaultLogLevel: 'trace', - // The following are too verbose in their logging with the default level - 'modules/RTC/TraceablePeerConnection.js': 'info', - 'modules/statistics/CallStats.js': 'info', - 'modules/xmpp/strophe.util.js': 'log', - }, + // The following are too verbose in their logging with the default level + 'modules/RTC/TraceablePeerConnection.js': 'info', + 'modules/statistics/CallStats.js': 'info', + 'modules/xmpp/strophe.util.js': 'log', + }, - // End marker, disregard - __end: true, -}) + // End marker, disregard + __end: true, + } +} export const meetLowLevel = { connectionStarted: false, @@ -305,20 +311,22 @@ export const meetLowLevel = { }) .catch((err) => console.error('An error occured while creating local tracks', err)) - const connection = new jitsiMeetJS.JitsiConnection(null, null, options) + Meteor.call('computeRoomToken', this.roomName, (err, token) => { + const connection = new jitsiMeetJS.JitsiConnection(null, token, options) - connection.addEventListener(jitsiMeetJS.events.connection.CONNECTION_ESTABLISHED, () => { - this.onConnectionSuccess() - }) - connection.addEventListener(jitsiMeetJS.events.connection.CONNECTION_FAILED, () => { - this.onConnectionFailed() - }) - connection.addEventListener(jitsiMeetJS.events.connection.CONNECTION_DISCONNECTED, () => { - this.onConnectionDisconnected() - }) + connection.addEventListener(jitsiMeetJS.events.connection.CONNECTION_ESTABLISHED, () => { + this.onConnectionSuccess() + }) + connection.addEventListener(jitsiMeetJS.events.connection.CONNECTION_FAILED, () => { + this.onConnectionFailed() + }) + connection.addEventListener(jitsiMeetJS.events.connection.CONNECTION_DISCONNECTED, () => { + this.onConnectionDisconnected() + }) - connection.connect() - this.template.connection.set(connection) + connection.connect() + this.template.connection.set(connection) + }) } }, diff --git a/core/modules/meet/server/meet.js b/core/modules/meet/server/meet.js index a5e81c53..774c198f 100644 --- a/core/modules/meet/server/meet.js +++ b/core/modules/meet/server/meet.js @@ -55,6 +55,19 @@ const updateUserRoomName = (roomName) => { } Meteor.methods({ + computeRoomToken(roomName) { + check(roomName, Match.Maybe(String)) + const user = Meteor.user() + if (!user) return + + log('computeRoomToken: start', { roomName }) + const token = computeRoomToken(user, roomName) + log('computeRoomToken: end', { roomName }) + + return token + }, + + // Meet conference computeMeetRoomAccess(zoneId) { if (!this.userId) return undefined check(zoneId, Match.Id) @@ -79,6 +92,8 @@ Meteor.methods({ return { roomName, token } }, + + // Meet low level updateUserRoomName(roomName) { check(roomName, Match.Maybe(String)) const user = Meteor.user()