Skip to content

Commit

Permalink
phoneIslandEvents. Added open and close events for transfer and socket (
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyco97 authored Aug 2, 2024
1 parent 6111dc3 commit 460ed41
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
20 changes: 19 additions & 1 deletion docs/EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,13 @@ eventDispatch(`<event-name>`, `<data-object>`)
{}
```

- `phone-island-call-transfer-successfully` The event to advert if a transfer has been made successfully
- `phone-island-call-transfer-successfully-popup-open` The event to advert if a transfer has been made successfully and phone-island popup is open

```json
{}
```

- `phone-island-call-transfer-successfully-popup-close` The event to advert if a transfer has been made successfully and phone-island popup is close

```json
{}
Expand Down Expand Up @@ -831,3 +837,15 @@ eventDispatch(`<event-name>`, `<data-object>`)
```json
{}
```

- `phone-island-socket-disconnected-popup-open` Indicates that webscket connection missing popup appear

```json
{}
```

- `phone-island-socket-disconnected-popup-close` Indicates that webscket connection missing popup disappear

```json
{}
```
8 changes: 6 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,12 @@ export const PhoneIsland: FC<PhoneIslandProps> = ({
eventDispatch('phone-island-default-device-changed', {})
})

useEventListener('phone-island-call-transfer-successfully', () => {
console.log('Call transferred successfully')
useEventListener('phone-island-call-transfer-successfully-popup-open', () => {
console.log('Call transferred successfully and popup opened')
})

useEventListener('phone-island-call-transfer-successfully-popup-close', () => {
console.log('Call transferred successfully and popup closed')
})

useEventListener('phone-island-call-transfer-failed', () => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/Hangup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ const Hangup: FC<HangupProps> = ({
if (transferring) {
setTimeout(() => {
dispatch.alerts.setAlert('call_transfered')
eventDispatch('phone-island-call-transfer-successfully', {})
eventDispatch('phone-island-call-transfer-successfully-popup-open', {})
setTimeout(() => {
dispatch.alerts.removeAlert('call_transfered')
eventDispatch('phone-island-call-transfer-successfully-popup-close', {})
}, 2000)
}, 300)
}
Expand Down
3 changes: 2 additions & 1 deletion src/components/Socket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export const Socket: FC<SocketProps> = ({
() => {
// Remove socket_down alert
dispatch.alerts.removeAlert('socket_down')
eventDispatch('phone-island-socket-disconnected-popup-close', {})
// Calculate and log latency
const latency = Date.now() - start
console.debug(`Socket latency: ${latency}ms`)
Expand All @@ -277,7 +278,7 @@ export const Socket: FC<SocketProps> = ({
() => {
// Set socket_down alert
dispatch.alerts.setAlert('socket_down')
eventDispatch('phone-island-socket-disconnected', {})
eventDispatch('phone-island-socket-disconnected-popup-open', {})
console.debug('Socket is unreachable!')
},
7 * 1000, // Waits for the response 7 seconds
Expand Down

0 comments on commit 460ed41

Please sign in to comment.