Skip to content
This repository was archived by the owner on Sep 13, 2023. It is now read-only.

Commit 182e1e0

Browse files
committed
Connect meet low level to the jitsi provider
1 parent a2beb61 commit 182e1e0

File tree

2 files changed

+75
-52
lines changed

2 files changed

+75
-52
lines changed

core/modules/meet/client/meet-low-level.js

Lines changed: 60 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -228,53 +228,59 @@ const onUserPropertyUpdated = async (e, template) => {
228228
** LowMeetJs
229229
*/
230230

231-
const DOMAIN = '8x8.vc'
232-
const getOptions = () => ({
233-
// Connection
234-
hosts: {
235-
domain: DOMAIN,
236-
muc: `conference.${DOMAIN}`,
237-
focus: `focus.${DOMAIN}`,
238-
},
239-
serviceUrl: `wss://${DOMAIN}/xmpp-websocket?room=${meetLowLevel.roomName}`,
240-
websocketKeepAliveUrl: `https://${DOMAIN}/_unlock?room=${meetLowLevel.roomName}`,
231+
const getOptions = () => {
232+
const serverURL = Meteor.settings.public.meet.serverURL
233+
234+
if (!serverURL) return
235+
const [domain, sub] = serverURL.split('/')
236+
237+
return {
238+
// Connection
239+
hosts: {
240+
domain: serverURL,
241+
muc: `conference.${sub}.${domain}`,
242+
focus: `focus.${domain}`,
243+
},
244+
serviceUrl: `wss://${serverURL}/xmpp-websocket?room=${meetLowLevel.roomName}`,
245+
websocketKeepAliveUrl: `https://${serverURL}/_unlock?room=${meetLowLevel.roomName}`,
241246

242-
// Enable Peer-to-Peer for 1-1 calls
243-
p2p: {
244-
enabled: false,
245-
},
247+
// Enable Peer-to-Peer for 1-1 calls
248+
p2p: {
249+
enabled: false,
250+
},
246251

247-
// Video quality / constraints
248-
constraints: {
249-
video: {
250-
height: {
251-
ideal: 720,
252-
max: 720,
253-
min: 180,
254-
},
255-
width: {
256-
ideal: 1280,
257-
max: 1280,
258-
min: 320,
252+
// Video quality / constraints
253+
constraints: {
254+
video: {
255+
height: {
256+
ideal: 720,
257+
max: 720,
258+
min: 180,
259+
},
260+
width: {
261+
ideal: 1280,
262+
max: 1280,
263+
min: 320,
264+
},
259265
},
260266
},
261-
},
262-
channelLastN: 25,
267+
channelLastN: 25,
263268

264-
// Logging
265-
logging: {
266-
// Default log level
267-
defaultLogLevel: 'trace',
269+
// Logging
270+
logging: {
271+
// Default log level
272+
defaultLogLevel: 'trace',
268273

269-
// The following are too verbose in their logging with the default level
270-
'modules/RTC/TraceablePeerConnection.js': 'info',
271-
'modules/statistics/CallStats.js': 'info',
272-
'modules/xmpp/strophe.util.js': 'log',
273-
},
274+
// The following are too verbose in their logging with the default level
275+
'modules/RTC/TraceablePeerConnection.js': 'info',
276+
'modules/statistics/CallStats.js': 'info',
277+
'modules/xmpp/strophe.util.js': 'log',
278+
},
274279

275-
// End marker, disregard
276-
__end: true,
277-
})
280+
// End marker, disregard
281+
__end: true,
282+
}
283+
}
278284

279285
export const meetLowLevel = {
280286
connectionStarted: false,
@@ -305,20 +311,22 @@ export const meetLowLevel = {
305311
})
306312
.catch((err) => console.error('An error occured while creating local tracks', err))
307313

308-
const connection = new jitsiMeetJS.JitsiConnection(null, null, options)
314+
Meteor.call('computeRoomToken', this.roomName, (err, token) => {
315+
const connection = new jitsiMeetJS.JitsiConnection(null, token, options)
309316

310-
connection.addEventListener(jitsiMeetJS.events.connection.CONNECTION_ESTABLISHED, () => {
311-
this.onConnectionSuccess()
312-
})
313-
connection.addEventListener(jitsiMeetJS.events.connection.CONNECTION_FAILED, () => {
314-
this.onConnectionFailed()
315-
})
316-
connection.addEventListener(jitsiMeetJS.events.connection.CONNECTION_DISCONNECTED, () => {
317-
this.onConnectionDisconnected()
318-
})
317+
connection.addEventListener(jitsiMeetJS.events.connection.CONNECTION_ESTABLISHED, () => {
318+
this.onConnectionSuccess()
319+
})
320+
connection.addEventListener(jitsiMeetJS.events.connection.CONNECTION_FAILED, () => {
321+
this.onConnectionFailed()
322+
})
323+
connection.addEventListener(jitsiMeetJS.events.connection.CONNECTION_DISCONNECTED, () => {
324+
this.onConnectionDisconnected()
325+
})
319326

320-
connection.connect()
321-
this.template.connection.set(connection)
327+
connection.connect()
328+
this.template.connection.set(connection)
329+
})
322330
}
323331
},
324332

core/modules/meet/server/meet.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,19 @@ const updateUserRoomName = (roomName) => {
5555
}
5656

5757
Meteor.methods({
58+
computeRoomToken(roomName) {
59+
check(roomName, Match.Maybe(String))
60+
const user = Meteor.user()
61+
if (!user) return
62+
63+
log('computeRoomToken: start', { roomName })
64+
const token = computeRoomToken(user, roomName)
65+
log('computeRoomToken: end', { roomName })
66+
67+
return token
68+
},
69+
70+
// Meet conference
5871
computeMeetRoomAccess(zoneId) {
5972
if (!this.userId) return undefined
6073
check(zoneId, Match.Id)
@@ -79,6 +92,8 @@ Meteor.methods({
7992

8093
return { roomName, token }
8194
},
95+
96+
// Meet low level
8297
updateUserRoomName(roomName) {
8398
check(roomName, Match.Maybe(String))
8499
const user = Meteor.user()

0 commit comments

Comments
 (0)