Class wsc.DataTransfer
Manage a data channel between two peers.
Constructor Attributes | Constructor Name and Description |
---|---|
An instance of this class is created by the Call object if the CallConfig includes the data channel.
|
Field Attributes | Field Name and Description |
---|---|
The label of the data channel indicated by this DataTransfer object.
|
Method Attributes | Method Name and Description |
---|---|
Returns the DataReceiver object of the DataTransfer.
|
|
Returns the DataSender object of the DataTransfer.
|
|
getState()
Returns a string indicating the status of the DataTransfer object.
|
Event Attributes | Event Name and Description |
---|---|
onClose()
Event handler called when the dataChannel of a DataTransfer object is closed.
|
|
onError()
Event handler called when the dataChannel of a DataTransfer object encounters an error.
|
|
onOpen()
Event handler called when the dataChannel of a DataTransfer object is opened.
|
Class Detail
wsc.DataTransfer()
An instance of this class is created by the Call object if the CallConfig includes the data channel.
It is returned to users by the Call object's callback function onDataTransfer(dataTransfer).
- See:
- wsc.Call
Field Detail
label
The label of the data channel indicated by this DataTransfer object.
Method Detail
{wsc.DataReceiver}
getReceiver()
Returns the DataReceiver object of the DataTransfer.
The member DataReceiver will be created when a data channel is set up successfully.
- Returns:
- {wsc.DataReceiver} object
{wsc.DataSender}
getSender()
Returns the DataSender object of the DataTransfer.
The member DataSender will be created when a data channel is set up successfully.
- Returns:
- {wsc.DataSender} object
{String}
getState()
Returns a string indicating the status of the DataTransfer object.
It can return one of the following values:
It can return one of the following values:
- none: the DataTransfer object is created but no data channel is established or initializing
- starting: the data channel is initializing or in negotiation to be established
- open: the data channel is established successfully and the ready state of data channel is open
- closed: the data channel has been closed
- Returns:
- {String} "none", "starting", "open," or "closed"
Event Detail
onClose()
Event handler called when the dataChannel of a DataTransfer object is closed.
An event is provided as parameter, when the handler is invoked.
function onDataTransfer(dataTransfer) { console.log("Data transfer call back is called!"); // Keep the dataTransfer reference, and initialize the dataTransfer callback functions... myDataTransfer = dataTransfer; myDataTransfer.onOpen = onDCOpen; myDataTransfer.onError = onDCError; myDataTransfer.onClose = onDCClose; } function onDCClose(evt) { // Render the web page when the data channel is closed. }
onError()
Event handler called when the dataChannel of a DataTransfer object encounters an error.
An event is provided as parameter, when the handler is invoked.
function onDataTransfer(dataTransfer) { console.log("Data transfer call back called."); // Keep the dataTransfer reference, and initialize the dataTransfer callback functions... myDataTransfer = dataTransfer; myDataTransfer.onOpen = onDCOpen; myDataTransfer.onError = onDCError; myDataTransfer.onClose = onDCClose; } function onDCError(evt) { // Handle the error, and render the web page as appropriate. }
onOpen()
Event handler called when the dataChannel of a DataTransfer object is opened.
An event is provided as parameter, when the handler is invoked.
function onDataTransfer(dataTransfer) { console.log("Data transfer call back is called!"); //keep the reference of dataTransfer, and initial the callback functions of dataTransfer. myDataTransfer = dataTransfer; myDataTransfer.onOpen = onDCOpen; myDataTransfer.onError = onDCError; myDataTransfer.onClose = onDCClose; } function onDCOpen(evt) { //do some render for web page when data channel is open }