v1.3.0-beta/pin for create and join
This commit is contained in:
+21
-8
@@ -6,6 +6,7 @@ class CallManager {
|
|||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
this.__refreshToken = null;
|
this.__refreshToken = null;
|
||||||
this.__accessToken = null;
|
this.__accessToken = null;
|
||||||
|
this.__sessionInitialized = false;
|
||||||
}
|
}
|
||||||
toggleCall(onCall, conferenceRoomId) {
|
toggleCall(onCall, conferenceRoomId) {
|
||||||
if (onCall === true) this.leaveCall();
|
if (onCall === true) this.leaveCall();
|
||||||
@@ -13,25 +14,37 @@ class CallManager {
|
|||||||
}
|
}
|
||||||
async boot(conferenceRoomId) {
|
async boot(conferenceRoomId) {
|
||||||
if (
|
if (
|
||||||
this.__accessToken !== undefined &&
|
this.__accessToken !== undefined ||
|
||||||
this.__refreshToken !== undefined &&
|
this.__refreshToken !== undefined ||
|
||||||
this.__accessToken !== null &&
|
this.__accessToken !== null ||
|
||||||
this.__refreshToken !== 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 {
|
try {
|
||||||
await VoxeetSDK.session.open({
|
await VoxeetSDK.session.open({
|
||||||
externalId: window.localStorage.getItem('watchPartyUserUid'),
|
externalId: window.localStorage.getItem('watchPartyUserUid'),
|
||||||
name: window.localStorage.getItem('watchPartyUserName'),
|
name: window.localStorage.getItem('watchPartyUserName'),
|
||||||
});
|
});
|
||||||
|
return true;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error Opening Voxeet Session', error);
|
console.error('Error Opening Voxeet Session', error);
|
||||||
}
|
}
|
||||||
} else {
|
return false;
|
||||||
this.initialize();
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
async leaveCall() {}
|
|
||||||
async openSession() {}
|
|
||||||
async initialize() {
|
async initialize() {
|
||||||
GetVoxeetTokenApi()
|
GetVoxeetTokenApi()
|
||||||
.then((res) => res.json())
|
.then((res) => res.json())
|
||||||
|
|||||||
+23
-3
@@ -61,6 +61,7 @@ const createRoom = async (data) => {
|
|||||||
data.props.notify('Starting party...');
|
data.props.notify('Starting party...');
|
||||||
|
|
||||||
const apidata = {
|
const apidata = {
|
||||||
|
roomPin: data.createPin,
|
||||||
roomName: data.createName,
|
roomName: data.createName,
|
||||||
userName: data.name,
|
userName: data.name,
|
||||||
player: {
|
player: {
|
||||||
@@ -100,7 +101,9 @@ const createRoom = async (data) => {
|
|||||||
const Create = (props) => {
|
const Create = (props) => {
|
||||||
const [name, setName] = useState(getName() || '');
|
const [name, setName] = useState(getName() || '');
|
||||||
const [createName, setCreateName] = useState('');
|
const [createName, setCreateName] = useState('');
|
||||||
|
const [createPin, setCreatePin] = useState('');
|
||||||
const [joinName, setJoinName] = useState(getRoomId() || '');
|
const [joinName, setJoinName] = useState(getRoomId() || '');
|
||||||
|
const [joinPin, setJoinPin] = useState('');
|
||||||
const { notify } = props;
|
const { notify } = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -139,8 +142,17 @@ const Create = (props) => {
|
|||||||
helperText={createName.length > 0 ? `${createName.length}/24` : null}
|
helperText={createName.length > 0 ? `${createName.length}/24` : null}
|
||||||
label="Party Name"
|
label="Party Name"
|
||||||
/>
|
/>
|
||||||
|
<TextField
|
||||||
|
fullWidth
|
||||||
|
type="number"
|
||||||
|
value={createPin}
|
||||||
|
className="card-field addFocus"
|
||||||
|
onChange={(e) => (e.target.value.length <= 10 ? setCreatePin(e.target.value) : null)}
|
||||||
|
helperText={createPin.length > 0 ? `${createPin.length}/10` : null}
|
||||||
|
label="Pin Code"
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => createRoom({ name, createName, props })}
|
onClick={() => createRoom({ name, createName, props, createPin })}
|
||||||
disabled={createName === ''}
|
disabled={createName === ''}
|
||||||
color="primary"
|
color="primary"
|
||||||
fullWidth
|
fullWidth
|
||||||
@@ -159,11 +171,19 @@ const Create = (props) => {
|
|||||||
value={joinName}
|
value={joinName}
|
||||||
className="card-field addFocus"
|
className="card-field addFocus"
|
||||||
onChange={(e) => setJoinName(e.target.value)}
|
onChange={(e) => setJoinName(e.target.value)}
|
||||||
label="Party Code"
|
label="Party Name"
|
||||||
|
/>
|
||||||
|
<TextField
|
||||||
|
fullWidth
|
||||||
|
type="number"
|
||||||
|
value={joinPin}
|
||||||
|
className="card-field addFocus"
|
||||||
|
onChange={(e) => setJoinPin(e.target.value)}
|
||||||
helperText="Ask your party leader for this code"
|
helperText="Ask your party leader for this code"
|
||||||
|
label="Pin Code"
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
onClick={() => joinRoom({ joinName, name, props })}
|
onClick={() => joinRoom({ joinName, name, props, joinPin })}
|
||||||
disabled={joinName === ''}
|
disabled={joinName === ''}
|
||||||
variant="contained"
|
variant="contained"
|
||||||
color="secondary"
|
color="secondary"
|
||||||
|
|||||||
Reference in New Issue
Block a user