Changeset View
Standalone View
src/resources/vue/Meet/Room.vue
Show First 20 Lines • Show All 220 Lines • ▼ Show 20 Lines | export default { | ||||
meet: null, | meet: null, | ||||
microphone: '', | microphone: '', | ||||
nickname: '', | nickname: '', | ||||
password: '', | password: '', | ||||
room: null, | room: null, | ||||
roomState: 'init', | roomState: 'init', | ||||
roomStateLabels: { | roomStateLabels: { | ||||
init: 'Checking the room...', | init: 'Checking the room...', | ||||
404: 'The room does not exist.', | |||||
323: 'The room is closed. Please, wait for the owner to start the session.', | 323: 'The room is closed. Please, wait for the owner to start the session.', | ||||
324: 'The room is closed. It will be open for others after you join.', | 324: 'The room is closed. It will be open for others after you join.', | ||||
325: 'The room is ready. Please, provide a valid password.', | 325: 'The room is ready. Please, provide a valid password.', | ||||
326: 'The room is locked. Please, enter your name and try again.', | 326: 'The room is locked. Please, enter your name and try again.', | ||||
327: 'Waiting for permission to join the room.', | 327: 'Waiting for permission to join the room.', | ||||
500: 'Failed to create a session. Server error.' | 404: 'The room does not exist.', | ||||
429: 'Too many requests. Please, wait.', | |||||
500: 'Failed to connect to the room. Server error.' | |||||
}, | }, | ||||
session: {} | session: {} | ||||
} | } | ||||
}, | }, | ||||
mounted() { | mounted() { | ||||
this.room = this.$route.params.room | this.room = this.$route.params.room | ||||
// Initialize OpenVidu and do some basic checks | // Initialize OpenVidu and do some basic checks | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | export default { | ||||
const data = error.response.data || {} | const data = error.response.data || {} | ||||
if (data.code) { | if (data.code) { | ||||
this.roomState = data.code | this.roomState = data.code | ||||
} else { | } else { | ||||
this.roomState = error.response.status | this.roomState = error.response.status | ||||
} | } | ||||
button.prop('disabled', this.roomState == 'init' || this.roomState == 327 || this.roomState == 404) | button.prop('disabled', this.roomState == 'init' || this.roomState == 327 || this.roomState >= 400) | ||||
if (data.config) { | if (data.config) { | ||||
this.session.config = data.config | this.session.config = data.config | ||||
} | } | ||||
switch (this.roomState) { | switch (this.roomState) { | ||||
case 323: | case 323: | ||||
// Waiting for the owner to open the room... | // Waiting for the owner to open the room... | ||||
Show All 20 Lines | export default { | ||||
} | } | ||||
break; | break; | ||||
case 327: | case 327: | ||||
// Waiting for the owner's approval to join | // Waiting for the owner's approval to join | ||||
// Update room state every 10 seconds | // Update room state every 10 seconds | ||||
roomRequest = setTimeout(() => { this.initSession(true) }, 10000) | roomRequest = setTimeout(() => { this.initSession(true) }, 10000) | ||||
break; | break; | ||||
case 429: | |||||
// Rate limited, wait and try again | |||||
const waitTime = error.response.headers['retry-after'] || 10 | |||||
roomRequest = setTimeout(() => { this.initSession(init) }, waitTime * 1000) | |||||
break; | |||||
default: | |||||
if (this.roomState >= 400 && this.roomState != 404) { | |||||
mollekopf: Do we need a room state label for 422 as well above? | |||||
Done Inline ActionsI don't think so. A 422 response should contain the 3xx code response in the json data. In normal circumstances there will be no 422 response without the 3xx code in json response. machniak: I don't think so. A 422 response should contain the 3xx code response in the json data. In… | |||||
Not Done Inline ActionsI don't follow. It seems to me this.roomState can be equal to 422, and in this case it seems like there should be a corresponding label, unless the label is somehow not displayed, in which case I don't get why we need to make an exception for 422. If you are certain it's correct, that's fine by me. mollekopf: I don't follow. It seems to me this.roomState can be equal to 422, and in this case it seems… | |||||
this.roomState = 500 | |||||
} | |||||
} | } | ||||
}) | }) | ||||
if (document.fullscreenEnabled) { | if (document.fullscreenEnabled) { | ||||
$('#meet-session-menu').find('.link-fullscreen.closed').removeClass('hidden') | $('#meet-session-menu').find('.link-fullscreen.closed').removeClass('hidden') | ||||
} | } | ||||
}, | }, | ||||
isModerator() { | isModerator() { | ||||
▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | export default { | ||||
} | } | ||||
if (this.roomState == 323) { | if (this.roomState == 323) { | ||||
$('#meet-setup').addClass('hidden') | $('#meet-setup').addClass('hidden') | ||||
$('#meet-auth').removeClass('hidden') | $('#meet-auth').removeClass('hidden') | ||||
return | return | ||||
} | } | ||||
if (this.roomState != 'ready') { | if (this.roomState != 'ready' && !this.session.token) { | ||||
Not Done Inline ActionsA session.token seems to be implied by a 'ready' state. Can we somehow loose the token? mollekopf: A session.token seems to be implied by a 'ready' state. Can we somehow loose the token? | |||||
Done Inline ActionsNo, you can't loose the (main) token. Here we're preventing from calling initSession() again if the token has been already acquired. It's needed because after openvidu connection error we might end up in joinSession() again. machniak: No, you can't loose the (main) token. Here we're preventing from calling initSession() again if… | |||||
this.initSession(true) | this.initSession(true) | ||||
return | return | ||||
} | } | ||||
clearTimeout(roomRequest) | clearTimeout(roomRequest) | ||||
this.session.nickname = this.nickname | |||||
this.session.menuElement = $('#meet-session-menu')[0] | |||||
this.session.chatElement = $('#meet-chat')[0] | |||||
this.session.onSuccess = () => { | |||||
$('#app').addClass('meet') | $('#app').addClass('meet') | ||||
$('#meet-setup').addClass('hidden') | $('#meet-setup').addClass('hidden') | ||||
$('#meet-session-toolbar,#meet-session-layout').removeClass('hidden') | $('#meet-session-toolbar,#meet-session-layout').removeClass('hidden') | ||||
if (!this.canShareScreen) { | if (!this.canShareScreen) { | ||||
this.setMenuItem('screen', false, true) | this.setMenuItem('screen', false, true) | ||||
} | } | ||||
} | |||||
this.session.nickname = this.nickname | this.session.onError = () => { | ||||
this.session.menuElement = $('#meet-session-menu')[0] | this.roomState = 500 | ||||
this.session.chatElement = $('#meet-chat')[0] | } | ||||
this.session.onDestroy = event => { | this.session.onDestroy = event => { | ||||
// TODO: Display different message for each reason: forceDisconnectByUser, | // TODO: Display different message for each reason: forceDisconnectByUser, | ||||
// forceDisconnectByServer, sessionClosedByServer? | // forceDisconnectByServer, sessionClosedByServer? | ||||
if (event.reason != 'disconnect' && event.reason != 'networkDisconnect' && !this.isRoomOwner()) { | if (event.reason != 'disconnect' && event.reason != 'networkDisconnect' && !this.isRoomOwner()) { | ||||
$('#leave-dialog').on('hide.bs.modal', () => { | $('#leave-dialog').on('hide.bs.modal', () => { | ||||
// FIXME: Where exactly the user should land? Currently he'll land | // FIXME: Where exactly the user should land? Currently he'll land | ||||
// on dashboard (if he's logged in) or login form (if he's not). | // on dashboard (if he's logged in) or login form (if he's not). | ||||
▲ Show 20 Lines • Show All 214 Lines • Show Last 20 Lines |
Do we need a room state label for 422 as well above?