new LocalDataTrack( [options])
Construct a LocalDataTrack.
Extends:
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
options |
LocalDataTrackOptions |
<optional> |
LocalDataTrack options |
Properties:
Name | Type | Argument | Description |
---|---|---|---|
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({ 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(message); // { x: <number>, y: <number> } }); }); });
Extends
Members
-
id
-
The Track's ID.
Methods
-
send(data)
-
Send a message over the LocalDataTrack.
Parameters:
Name Type Description data
string | Blob | ArrayBuffer | ArrayBufferView Returns:
- Type
- void