Skip to content

Commit

Permalink
UI requests
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsantosbh committed Feb 21, 2024
1 parent 5458c77 commit e26b818
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 96 deletions.
196 changes: 103 additions & 93 deletions public/full.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,18 @@ async function enablePushNotifications() {

FB.onMessage(messaging, (payload) => {
console.log('Push payload.data.message', payload.data.message)
const message = JSON.parse(payload.data.message);
const message = JSON.parse(payload.data.message)
handlePushNotification(message.notification.body)
alert(body.title)
})

try {
navigator.serviceWorker.addEventListener('message', event => {
console.log(`The service worker sent me a message: ${event.data}`);
navigator.serviceWorker.addEventListener('message', (event) => {
console.log(`The service worker sent me a message: ${event.data}`)
const message = JSON.parse(event.data || '{}')
handlePushNotification(message.notification.body)
alert(body.title)
});
})

const registration = await navigator.serviceWorker.register(
'/service-worker.js',
Expand Down Expand Up @@ -392,107 +392,113 @@ window.connect = async () => {
return !!formValue && formValue.trim().length ? formValue.trim() : undefined
}

const call = await client.dial({
to: document.getElementById('destination').value,
logLevel: 'debug',
debug: { logWsTraffic: true },
nodeId: steeringId(),
})
try {
const call = await client.dial({
to: document.getElementById('destination').value,
logLevel: 'debug',
debug: { logWsTraffic: true },
nodeId: steeringId(),
})

window.__call = call
roomObj = call
window.__call = call
roomObj = call

await call.start()
await call.start()

console.debug('Call Obj', call)
console.debug('Call Obj', call)

const joinHandler = (params) => {
console.debug('>> room.joined', params)
const joinHandler = (params) => {
console.debug('>> room.joined', params)

updateUIConnected()
updateUIConnected()

// loadLayouts()
}
joinHandler()
// loadLayouts()
}
joinHandler()

roomObj.on('media.connected', () => {
console.debug('>> media.connected')
})
roomObj.on('media.reconnecting', () => {
console.debug('>> media.reconnecting')
})
roomObj.on('media.disconnected', () => {
console.debug('>> media.disconnected')
})
roomObj.on('media.connected', () => {
console.debug('>> media.connected')
})
roomObj.on('media.reconnecting', () => {
console.debug('>> media.reconnecting')
})
roomObj.on('media.disconnected', () => {
console.debug('>> media.disconnected')
})

roomObj.on('room.started', (params) =>
console.debug('>> room.started', params)
)
roomObj.on('room.started', (params) =>
console.debug('>> room.started', params)
)

roomObj.on('destroy', () => {
console.debug('>> destroy')
restoreUI()
})
roomObj.on('room.updated', (params) =>
console.debug('>> room.updated', params)
)
roomObj.on('destroy', () => {
console.debug('>> destroy')
restoreUI()
})
roomObj.on('room.updated', (params) =>
console.debug('>> room.updated', params)
)

roomObj.on('recording.started', (params) => {
console.debug('>> recording.started', params)
document.getElementById('recordingState').innerText = 'recording'
})
roomObj.on('recording.ended', (params) => {
console.debug('>> recording.ended', params)
document.getElementById('recordingState').innerText = 'completed'
})
roomObj.on('recording.updated', (params) => {
console.debug('>> recording.updated', params)
document.getElementById('recordingState').innerText = params.state
})
roomObj.on('room.ended', (params) => {
console.debug('>> room.ended', params)
hangup()
})
roomObj.on('member.joined', (params) =>
console.debug('>> member.joined', params)
)
roomObj.on('member.updated', (params) =>
console.debug('>> member.updated', params)
)

roomObj.on('member.updated.audio_muted', (params) =>
console.debug('>> member.updated.audio_muted', params)
)
roomObj.on('member.updated.video_muted', (params) =>
console.debug('>> member.updated.video_muted', params)
)

roomObj.on('member.left', (params) => console.debug('>> member.left', params))
roomObj.on('member.talking', (params) =>
console.debug('>> member.talking', params)
)
roomObj.on('layout.changed', (params) =>
console.debug('>> layout.changed', params)
)
roomObj.on('track', (event) => console.debug('>> DEMO track', event))

roomObj.on('playback.started', (params) => {
console.debug('>> playback.started', params)

playbackStarted()
})
roomObj.on('playback.ended', (params) => {
console.debug('>> playback.ended', params)
roomObj.on('recording.started', (params) => {
console.debug('>> recording.started', params)
document.getElementById('recordingState').innerText = 'recording'
})
roomObj.on('recording.ended', (params) => {
console.debug('>> recording.ended', params)
document.getElementById('recordingState').innerText = 'completed'
})
roomObj.on('recording.updated', (params) => {
console.debug('>> recording.updated', params)
document.getElementById('recordingState').innerText = params.state
})
roomObj.on('room.ended', (params) => {
console.debug('>> room.ended', params)
hangup()
})
roomObj.on('member.joined', (params) =>
console.debug('>> member.joined', params)
)
roomObj.on('member.updated', (params) =>
console.debug('>> member.updated', params)
)

playbackEnded()
})
roomObj.on('playback.updated', (params) => {
console.debug('>> playback.updated', params)
roomObj.on('member.updated.audio_muted', (params) =>
console.debug('>> member.updated.audio_muted', params)
)
roomObj.on('member.updated.video_muted', (params) =>
console.debug('>> member.updated.video_muted', params)
)

if (params.volume) {
document.getElementById('playbackVolume').value = params.volume
}
})
roomObj.on('member.left', (params) =>
console.debug('>> member.left', params)
)
roomObj.on('member.talking', (params) =>
console.debug('>> member.talking', params)
)
roomObj.on('layout.changed', (params) =>
console.debug('>> layout.changed', params)
)
roomObj.on('track', (event) => console.debug('>> DEMO track', event))

roomObj.on('playback.started', (params) => {
console.debug('>> playback.started', params)

playbackStarted()
})
roomObj.on('playback.ended', (params) => {
console.debug('>> playback.ended', params)

playbackEnded()
})
roomObj.on('playback.updated', (params) => {
console.debug('>> playback.updated', params)

if (params.volume) {
document.getElementById('playbackVolume').value = params.volume
}
})
} catch (e) {
alert(`Something went wrong trying to dial ${document.getElementById('destination').value}`);
}
}

function updateUIRinging() {
Expand Down Expand Up @@ -563,6 +569,10 @@ window.ready = (callback) => {
}
})
}
const steerEl = document.getElementById('steeringId')
steerEl.value =
localStorage.getItem('fabric.ws.steeringId') || ''
steerEl.onblur = (ev) => localStorage.setItem('fabric.ws.steeringId', ev.target.value)
}

let screenShareObj
Expand Down
4 changes: 1 addition & 3 deletions views/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -442,9 +442,7 @@
const _firebaseConfig = <%- firebaseConfig %>;
</script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
<!-- script type="text/javascript" src="https://unpkg.com/@signalwire/js@dev"></script -->
<script src="/index.umd.js"></script>
<script src="/full.js"></script>
<script type="text/javascript" src="https://unpkg.com/@signalwire/js@dev"></script>
</body>

</html>

0 comments on commit e26b818

Please sign in to comment.