From c5381d40df69b2b11a973df961aca4b9d09d8892 Mon Sep 17 00:00:00 2001 From: Charlemagne Santos Date: Wed, 26 Oct 2022 10:30:15 -0700 Subject: [PATCH] Adding changelog draft (#123) * Adding changelog draft * Adding Kumkum's suggestion. --- CHANGELOG.md | 35 ++++++++++++++++++++++++++++++++++- lib/twilio/call.ts | 4 ++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b780f798..36c05af9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,40 @@ New Features ------------ -TODO: Need to coordinate with DevEd and Backend Docs +### SDK Message Events (Beta) + +// TODO: Polish up, add links to public documentation, update API doc links to typedoc after cutting a release + +The SDK can now send and receive custom messages to and from Twilio's backend via the following new `Call` APIs. + +- [sendMessage](https://twilio.github.io/twilio-voice.js/classes/voice.call.html#sendmessage) +- [messageReceivedEvent](https://twilio.github.io/twilio-voice.js/classes/voice.call.html#messagereceivedevent) +- [messageSentEvent](https://twilio.github.io/twilio-voice.js/classes/voice.call.html#messagesentevent) + +**Example** + +```js +const device = new Device(token, options); + +const setupCallHandlers = call => { + call.on('messageReceived', message => messageReceivedHandler(message)); + call.on('messageSent', message => messageSentHandler(message)); +}; + +// For outgoing calls +const call = await device.connect(); +setupCallHandlers(call); + +// For incoming calls +device.on('incoming', call => setupCallHandlers(call)); +await device.register(); + +// For sending a message +const eventSid = call.sendMessage({ + content: { foo: 'foo' }, + messageType: Call.MessageType.UserDefinedMessage, +}); +``` 2.1.2 (In Progress) ========================= diff --git a/lib/twilio/call.ts b/lib/twilio/call.ts index 5489162a..6d54c7a3 100644 --- a/lib/twilio/call.ts +++ b/lib/twilio/call.ts @@ -1537,8 +1537,8 @@ namespace Call { declare function messageReceivedEvent(message: Call.Message): void; /** - * Emitted after calling the {@link Call.sendMessage} API and that - * Twilio has received the message. + * Emitted after calling the {@link Call.sendMessage} API. + * This event indicates that Twilio has received the message. * @param message - A message object that was sent to the Twilio backend. * @event */