new Twilio.Video.LocalDataTrack( [options])
Construct a LocalDataTrack.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
options |
LocalDataTrackOptions |
<optional> |
LocalDataTrack options |
Properties:
Name | Type | Argument | Description |
---|---|---|---|
id |
Track.ID | The LocalDataTrack's ID |
|
kind |
Track.Kind | "data" |
|
maxPacketLifeTime |
number |
<nullable> |
If non-null, this represents a time limit (in milliseconds) during which the LocalDataTrack will send or re-send data if not acknowledged on the underlying RTCDataChannel(s). |
maxRetransmits |
number |
<nullable> |
If non-null, this represents the number of times the LocalDataTrack will resend data if not successfully delivered on the underlying RTCDataChannel(s). |
ordered |
boolean | true if data on the LocalDataTrack is guaranteed to be sent in order. |
|
reliable |
boolean | This is true if both
|
Example
var Video = require('twilio-video'); var localDataTrack = new Video.LocalDataTrack(); window.addEventListener('mousemove', function(event) { localDataTrack.send(JSON.stringify({ x: e.clientX, y: e.clientY })); }); var token1 = getAccessToken(); Video.connect(token1, { name: 'my-cool-room', tracks: [localDataTrack] }); var token2 = getAccessToken(); Video.connect(token2, { name: 'my-cool-room', tracks: [] }).then(function(room) { room.on('trackSubscribed', function(track) { track.on('message', function(message) { console.log(JSON.parse(message)); // { x: <number>, y: <number> } }); }); });
Extends
Methods
-
send(data)
-
Send a message over the LocalDataTrack.
Parameters:
Name Type Description data
string | Blob | ArrayBuffer | ArrayBufferView Returns:
- Type
- void