Twilio-video.js: Incorrect example for data track message

Created on 28 Apr 2020  路  3Comments  路  Source: twilio/twilio-video.js

The documentation at the link below states we're able to send a data message of type: string | Blob | ArrayBuffer | ArrayBufferView

However, the example right above it suggests it's also possible to pass an object. From my testing, this does not seem to be the case -- I have not been able to send an object. I'm assuming the example is incorrect?

https://media.twiliocdn.com/sdk/js/video/releases/2.0.0/docs/LocalDataTrack.html#send__anchor

bug filed

All 3 comments

Thank you @HandsomeMedia for reporting this issue. You are right that the example is incorrect. I have filed a bug (JSDK-2784) to track this issue. We will get the example fixed in next release.

As you must have figured out, you need to convert objects to one of the supported types before passing over data channels - for small objects JSON.stringify would be the easiest.

Thanks,
Makarand

Hi @HandsomeMedia ,

We have released 2.4.0, which has the corrected example in the documentation. I will close this issue now. Thanks for bringing it to our notice.

Thanks,

Manjesh Malavalli
JSDK Team

The typescript types are showing only string and ArrayBuffer can be received. Is this correct?
if it is, can an example for how to handle sending and receiving blob be also added?

(method) RemoteDataTrack.on(event: "message", listener: (data: string | ArrayBuffer, track: Video.RemoteDataTrack) => void): Video.RemoteDataTrack (+3 overloads)

Was this page helpful?
0 / 5 - 0 ratings