Changeset View
Changeset View
Standalone View
Standalone View
src/resources/js/meet/app.js
Show All 38 Lines | function Meet(container) | ||||
let containerWidth | let containerWidth | ||||
let containerHeight | let containerHeight | ||||
let chatCount = 0 | let chatCount = 0 | ||||
let volumeElement | let volumeElement | ||||
let subscribersContainer | let subscribersContainer | ||||
OV = new OpenVidu() | OV = new OpenVidu() | ||||
screenOV = new OpenVidu() | |||||
// If there's anything to do, do it here. | // If there's anything to do, do it here. | ||||
//OV.setAdvancedConfiguration(config) | //OV.setAdvancedConfiguration(config) | ||||
// Disable all logging except errors | // Disable all logging except errors | ||||
// OV.enableProdMode() | // OV.enableProdMode() | ||||
// Disconnect participant when browser's window close | // Disconnect participant when browser's window close | ||||
▲ Show 20 Lines • Show All 70 Lines • ▼ Show 20 Lines | function joinRoom(data) { | ||||
connections[connId] = metadata | connections[connId] = metadata | ||||
// Send the current user status to the connecting user | // Send the current user status to the connecting user | ||||
// otherwise e.g. nickname might be not up to date | // otherwise e.g. nickname might be not up to date | ||||
signalUserUpdate(event.connection) | signalUserUpdate(event.connection) | ||||
}) | }) | ||||
session.on('connectionDestroyed', event => { | session.on('connectionDestroyed', event => { | ||||
let conn = connections[event.connection.connectionId] | let connectionId = event.connection.connectionId | ||||
let conn = connections[connectionId] | |||||
if (conn) { | if (conn) { | ||||
$(conn.element).remove() | $(conn.element).remove() | ||||
delete connections[event.connection.connectionId] | delete connections[connectionId] | ||||
} | } | ||||
resize() | resize() | ||||
}) | }) | ||||
// On every new Stream received... | // On every new Stream received... | ||||
session.on('streamCreated', event => { | session.on('streamCreated', event => { | ||||
let connectionId = event.stream.connection.connectionId | let connectionId = event.stream.connection.connectionId | ||||
let metadata = connections[connectionId] | let metadata = connections[connectionId] | ||||
let props = { | let props = { | ||||
▲ Show 20 Lines • Show All 537 Lines • ▼ Show 20 Lines | function switchVideo() { | ||||
return videoActive | return videoActive | ||||
} | } | ||||
/** | /** | ||||
* Switch on/off screen sharing | * Switch on/off screen sharing | ||||
*/ | */ | ||||
function switchScreen(callback) { | function switchScreen(callback) { | ||||
if (screenPublisher) { | if (screenPublisher) { | ||||
// Note: This is what the original openvidu-call app does. | |||||
// It is probably better for performance reasons to close the connection, | |||||
// than to use unpublish() and keep the connection open. | |||||
screenSession.disconnect() | screenSession.disconnect() | ||||
screenSession = null | screenSession = null | ||||
screenPublisher = null | screenPublisher = null | ||||
if (callback) { | if (callback) { | ||||
// Note: Disconnecting invalidates the token. The callback should request | // Note: Disconnecting invalidates the token, we have to inform the vue component | ||||
// a new token for the next screen sharing session. | // to update UI state (and be prepared to request a new token). | ||||
callback(false) | callback(false) | ||||
} | } | ||||
return | return | ||||
} | } | ||||
screenConnect(callback) | screenConnect(callback) | ||||
} | } | ||||
▲ Show 20 Lines • Show All 489 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
function screenConnect(callback) { | function screenConnect(callback) { | ||||
if (!sessionData.shareToken) { | if (!sessionData.shareToken) { | ||||
return false | return false | ||||
} | } | ||||
let gotSession = !!screenSession | let gotSession = !!screenSession | ||||
if (!screenOV) { | |||||
screenOV = new OpenVidu() | |||||
} | |||||
// Init screen sharing session | // Init screen sharing session | ||||
if (!gotSession) { | if (!gotSession) { | ||||
screenSession = screenOV.initSession(); | screenSession = screenOV.initSession(); | ||||
} | } | ||||
let successFunc = function() { | let successFunc = function() { | ||||
screenSession.publish(screenPublisher) | screenSession.publish(screenPublisher) | ||||
screenSession.on('sessionDisconnected', event => { | |||||
callback(false) | |||||
screenSession = null | |||||
screenPublisher = null | |||||
}) | |||||
if (callback) { | if (callback) { | ||||
callback(true) | callback(true) | ||||
} | } | ||||
} | } | ||||
let errorFunc = function() { | let errorFunc = function() { | ||||
screenPublisher = null | screenPublisher = null | ||||
if (callback) { | if (callback) { | ||||
callback(false) | callback(false, true) | ||||
} | } | ||||
} | } | ||||
// Init the publisher | // Init the publisher | ||||
let params = { | let params = { | ||||
videoSource: 'screen', | videoSource: 'screen', | ||||
publishAudio: false | publishAudio: false | ||||
} | } | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |