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.__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())
|
||||
|
||||
+23
-3
@@ -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"
|
||||
/>
|
||||
<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
|
||||
onClick={() => createRoom({ name, createName, props })}
|
||||
onClick={() => createRoom({ name, createName, props, createPin })}
|
||||
disabled={createName === ''}
|
||||
color="primary"
|
||||
fullWidth
|
||||
@@ -159,11 +171,19 @@ const Create = (props) => {
|
||||
value={joinName}
|
||||
className="card-field addFocus"
|
||||
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"
|
||||
label="Pin Code"
|
||||
/>
|
||||
<Button
|
||||
onClick={() => joinRoom({ joinName, name, props })}
|
||||
onClick={() => joinRoom({ joinName, name, props, joinPin })}
|
||||
disabled={joinName === ''}
|
||||
variant="contained"
|
||||
color="secondary"
|
||||
|
||||
Reference in New Issue
Block a user