diff --git a/src/app/OpenVidu/Connection.php b/src/app/OpenVidu/Connection.php index d5c3bc92..cccde474 100644 --- a/src/app/OpenVidu/Connection.php +++ b/src/app/OpenVidu/Connection.php @@ -1,88 +1,98 @@ 'array', ]; /** * Dismiss (close) the connection. * * @return bool True on success, False on failure */ public function dismiss() { if ($this->room->closeOVConnection($this->id)) { $this->delete(); return true; } return false; } /** * The room to which this connection belongs. * * @return \Illuminate\Database\Eloquent\Relations\BelongsTo */ public function room() { return $this->belongsTo(Room::class, 'room_id', 'id'); } /** * Connection role mutator * * @throws \Exception */ public function setRoleAttribute($role) { $new_role = 0; $allowed_values = [ Room::ROLE_SUBSCRIBER, Room::ROLE_PUBLISHER, Room::ROLE_MODERATOR, Room::ROLE_SCREEN, Room::ROLE_OWNER, ]; foreach ($allowed_values as $value) { if ($role & $value) { $new_role |= $value; $role ^= $value; } } if ($role > 0) { throw new \Exception("Invalid connection role: {$role}"); } + // It is either screen sharing connection or publisher/subscriber connection + if ($new_role & Room::ROLE_SCREEN) { + if ($new_role & Room::ROLE_PUBLISHER) { + $new_role ^= Room::ROLE_PUBLISHER; + } + if ($new_role & Room::ROLE_SUBSCRIBER) { + $new_role ^= Room::ROLE_SUBSCRIBER; + } + } + $this->attributes['role'] = $new_role; } } diff --git a/src/resources/js/meet/app.js b/src/resources/js/meet/app.js index 8757aab9..9484c08a 100644 --- a/src/resources/js/meet/app.js +++ b/src/resources/js/meet/app.js @@ -1,1238 +1,1230 @@ import anchorme from 'anchorme' import { library } from '@fortawesome/fontawesome-svg-core' import { OpenVidu } from 'openvidu-browser' class Roles { static get SUBSCRIBER() { return 1 << 0; } static get PUBLISHER() { return 1 << 1; } static get MODERATOR() { return 1 << 2; } static get SCREEN() { return 1 << 3; } static get OWNER() { return 1 << 4; } } function Meet(container) { let OV // OpenVidu object to initialize a session let session // Session object where the user will connect let publisher // Publisher object which the user will publish 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 audioSource = '' // Currently selected microphone let videoSource = '' // Currently selected camera let sessionData // Room session metadata let screenOV // OpenVidu object to initialize a screen sharing session let screenSession // Session object where the user will connect for screen sharing let screenPublisher // Publisher object which the user will publish the screen sharing let publisherDefaults = { publishAudio: true, // Whether to start publishing with your audio unmuted or not publishVideo: true, // Whether to start publishing with your video enabled or not resolution: '640x480', // The resolution of your video frameRate: 30, // The frame rate of your video mirror: true // Whether to mirror your local video or not } let cameras = [] // List of user video devices let microphones = [] // List of user audio devices let connections = {} // Connected users in the session let containerWidth let containerHeight let chatCount = 0 let volumeElement let setupProps let subscribersContainer OV = new OpenVidu() screenOV = new OpenVidu() // If there's anything to do, do it here. //OV.setAdvancedConfiguration(config) // Disable all logging except errors // OV.enableProdMode() // Disconnect participant when browser's window close window.addEventListener('beforeunload', () => { leaveRoom() }) window.addEventListener('resize', resize) // Public methods this.isScreenSharingSupported = isScreenSharingSupported this.joinRoom = joinRoom this.leaveRoom = leaveRoom this.setup = setup this.setupSetAudioDevice = setupSetAudioDevice this.setupSetVideoDevice = setupSetVideoDevice this.switchAudio = switchAudio this.switchScreen = switchScreen this.switchVideo = switchVideo this.updateSession = updateSession /** * Join the room session * * @param data Session metadata and event handlers (token, shareToken, nickname, role, * chatElement, menuElement, onDestroy, onJoinRequest, onDismiss, onConnectionChange, * onSessionDataUpdate) */ function joinRoom(data) { resize(); volumeMeterStop() data.params = { nickname: data.nickname, // user nickname // avatar: undefined // avatar image } // Create a container for subscribers if (!subscribersContainer) { subscribersContainer = $('