Table of Contents

onDataReceived()

wrtc.onDataReceived() is an event function called when data has been received on a data channel.

You can use this event to take care of incoming data through a data channel.

Arguments

wrtc.onDataReceived(callobj, data)

Return value

Ignored.

Example

If sending client has sent "PING" using

if call.is("dataChannelSupport")
  call.adv.sendData("PING");

you will receive a wrtc.onDataReceived() call with "PING" in it's data argument. Then you can respond with "PONG":

wrtc.onDataReceived = function(callobj, data) {
  if (data == "PING")
    callobj.adv.sendData("PONG");
}

See also

data channels

call.adv.sendData()