From fba32fd7d18940a38001263a0e7f35563ddffa31 Mon Sep 17 00:00:00 2001 From: Ayushya Amitabh Date: Sat, 30 May 2020 12:58:40 -0400 Subject: [PATCH] v1.3.0-beta/pin for create and join --- app/src/CallManager.js | 29 +++++++++++++++++++++-------- app/src/Create.js | 26 +++++++++++++++++++++++--- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/app/src/CallManager.js b/app/src/CallManager.js index 73f8fd7..5455848 100644 --- a/app/src/CallManager.js +++ b/app/src/CallManager.js @@ -6,6 +6,7 @@ class CallManager { this.listener = listener; this.__refreshToken = null; this.__accessToken = null; + this.__sessionInitialized = false; } toggleCall(onCall, conferenceRoomId) { if (onCall === true) this.leaveCall(); @@ -13,25 +14,37 @@ class CallManager { } async boot(conferenceRoomId) { if ( - this.__accessToken !== undefined && - this.__refreshToken !== undefined && - this.__accessToken !== null && + this.__accessToken !== undefined || + this.__refreshToken !== undefined || + this.__accessToken !== null || this.__refreshToken !== null - ) { + ) + await this.initialize(); + const opened = await this.openSession(); + if (opened && conferenceRoomId) this.joinCall(conferenceRoomId); + else if (opened && !conferenceRoomId) this.startCall(conferenceRoomId); + else console.log('Unable to open Voxeet Session'); + } + async startCall(conferenceRoomId) { + VoxeetSDK.conference.create({ alias: window.localStorage.getItem('watchPartyRoomId') }); + } + async joinCall(conferenceRoomId) {} + async leaveCall() {} + async openSession() { + if (!this.__sessionInitialized) { try { await VoxeetSDK.session.open({ externalId: window.localStorage.getItem('watchPartyUserUid'), name: window.localStorage.getItem('watchPartyUserName'), }); + return true; } catch (error) { console.error('Error Opening Voxeet Session', error); } - } else { - this.initialize(); + return false; } + return true; } - async leaveCall() {} - async openSession() {} async initialize() { GetVoxeetTokenApi() .then((res) => res.json()) diff --git a/app/src/Create.js b/app/src/Create.js index bbeb0dd..7e22104 100644 --- a/app/src/Create.js +++ b/app/src/Create.js @@ -61,6 +61,7 @@ const createRoom = async (data) => { data.props.notify('Starting party...'); const apidata = { + roomPin: data.createPin, roomName: data.createName, userName: data.name, player: { @@ -100,7 +101,9 @@ const createRoom = async (data) => { const Create = (props) => { const [name, setName] = useState(getName() || ''); const [createName, setCreateName] = useState(''); + const [createPin, setCreatePin] = useState(''); const [joinName, setJoinName] = useState(getRoomId() || ''); + const [joinPin, setJoinPin] = useState(''); const { notify } = props; return ( @@ -139,8 +142,17 @@ const Create = (props) => { helperText={createName.length > 0 ? `${createName.length}/24` : null} label="Party Name" /> + (e.target.value.length <= 10 ? setCreatePin(e.target.value) : null)} + helperText={createPin.length > 0 ? `${createPin.length}/10` : null} + label="Pin Code" + />