Changeset View
Changeset View
Standalone View
Standalone View
src/resources/js/meet/app.js
import anchorme from 'anchorme' | import anchorme from 'anchorme' | ||||
import { library } from '@fortawesome/fontawesome-svg-core' | import { library } from '@fortawesome/fontawesome-svg-core' | ||||
import { OpenVidu } from 'openvidu-browser' | import { OpenVidu } from 'openvidu-browser' | ||||
class Roles { | class Roles { | ||||
static get SUBSCRIBER() { return 1 << 0; } | static get SUBSCRIBER() { return 1 << 0; } | ||||
static get PUBLISHER() { return 1 << 1; } | static get PUBLISHER() { return 1 << 1; } | ||||
static get MODERATOR() { return 1 << 2; } | static get MODERATOR() { return 1 << 2; } | ||||
static get SCREEN() { return 1 << 3; } | static get SCREEN() { return 1 << 3; } | ||||
static get OWNER() { return 1 << 4; } | static get OWNER() { return 1 << 4; } | ||||
} | } | ||||
// Disable jsnlog's error handlers added in OpenVidu 2.18 | |||||
// https://github.com/OpenVidu/openvidu/issues/631 | |||||
window.onerror = () => { return false } | |||||
window.onunhandledrejection = () => { return false } | |||||
function Meet(container) | function Meet(container) | ||||
{ | { | ||||
let OV // OpenVidu object to initialize a session | let OV // OpenVidu object to initialize a session | ||||
let session // Session object where the user will connect | let session // Session object where the user will connect | ||||
let publisher // Publisher object which the user will publish | let publisher // Publisher object which the user will publish | ||||
let audioActive = false // True if the audio track of the publisher is active | let audioActive = false // True if the audio track of the publisher is active | ||||
let videoActive = false // True if the video track of the publisher is active | let videoActive = false // True if the video track of the publisher is active | ||||
let audioSource = '' // Currently selected microphone | let audioSource = '' // Currently selected microphone | ||||
▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | function joinRoom(data) { | ||||
// we got from our database. | // we got from our database. | ||||
if (sessionData.connections && connId in sessionData.connections) { | if (sessionData.connections && connId in sessionData.connections) { | ||||
Object.assign(metadata, sessionData.connections[connId]) | Object.assign(metadata, sessionData.connections[connId]) | ||||
} | } | ||||
metadata.element = participantCreate(metadata) | metadata.element = participantCreate(metadata) | ||||
connections[connId] = metadata | connections[connId] = metadata | ||||
// Send the current user status to the connecting user | |||||
// otherwise e.g. nickname might be not up to date | |||||
signalUserUpdate(event.connection) | |||||
}) | }) | ||||
session.on('connectionDestroyed', event => { | session.on('connectionDestroyed', event => { | ||||
let connectionId = event.connection.connectionId | let connectionId = event.connection.connectionId | ||||
let conn = connections[connectionId] | let conn = connections[connectionId] | ||||
if (conn) { | if (conn) { | ||||
// Remove elements related to the participant | // Remove elements related to the participant | ||||
Show All 28 Lines | function joinRoom(data) { | ||||
tabindex: -1 | tabindex: -1 | ||||
}) | }) | ||||
resize() | resize() | ||||
}) | }) | ||||
// Update the wrapper controls/status | // Update the wrapper controls/status | ||||
participantUpdate(metadata.element, metadata) | participantUpdate(metadata.element, metadata) | ||||
// Send the current user status to the connecting user | |||||
// otherwise e.g. nickname might be not up to date | |||||
signalUserUpdate(event.stream.connection) | |||||
}) | }) | ||||
// Stream properties changes e.g. audio/video muted/unmuted | // Stream properties changes e.g. audio/video muted/unmuted | ||||
session.on('streamPropertyChanged', event => { | session.on('streamPropertyChanged', event => { | ||||
let connectionId = event.stream.connection.connectionId | let connectionId = event.stream.connection.connectionId | ||||
let metadata = connections[connectionId] | let metadata = connections[connectionId] | ||||
if (session.connection.connectionId == connectionId) { | if (session.connection.connectionId == connectionId) { | ||||
▲ Show 20 Lines • Show All 1,456 Lines • Show Last 20 Lines |