Skip to content

Commit

Permalink
Expose a dtmf function for Video RoomSession object (#909)
Browse files Browse the repository at this point in the history
* Expose the  function for Video RoomSession object

* function renamed to sendDigits
  • Loading branch information
iAmmar7 authored Nov 16, 2023
1 parent d564c37 commit 4ee7b6f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/fuzzy-flowers-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@signalwire/webrtc': minor
'@signalwire/core': minor
---

Expose the `sendDigits` function for Video RoomSession object
11 changes: 11 additions & 0 deletions packages/core/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ export interface BaseConnectionContract<
*/
setLocalStream(stream: MediaStream): Promise<MediaStream>

/**
* Send DTMF
* @param {string} dtmf
*
* @example
* ```typescript
* room.sendDigits('1')
* ```
*/
sendDigits(dtmf: string): Promise<void>

/** @internal */
stopOutboundAudio(): void
/** @internal */
Expand Down
9 changes: 6 additions & 3 deletions packages/webrtc/src/BaseConnection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,14 +909,17 @@ export class BaseConnection<EventTypes extends EventEmitter.ValidEventTypes>
}
}

/** @internal */
dtmf(dtmf: string) {
async sendDigits(dtmf: string) {
const rtcPeerId = this.callId
if (!rtcPeerId) {
throw new Error('Invalid RTCPeer ID to send DTMF')
}
const message = VertoInfo({ ...this.dialogParams(rtcPeerId), dtmf })
this.vertoExecute({ message, callID: rtcPeerId, node_id: this.nodeId })
await this.vertoExecute({
message,
callID: rtcPeerId,
node_id: this.nodeId,
})
}

/** @internal */
Expand Down

0 comments on commit 4ee7b6f

Please sign in to comment.