Search completed in 1.33 seconds.
8 results for "ondatachannel":
RTCPeerConnection.ondatachannel - Web APIs
WebAPIRTCPeerConnectionondatachannel
the rtcpeerconnection.ondatachannel property is an eventhandler which specifies a function which is called when the datachannel event occurs on an rtcpeerconnection.
... syntax rtcpeerconnection.ondatachannel = function; value set this property to be a function you provide which receives as input a single parameter: an rtcdatachannelevent which provides in its channel property the rtcdatachannel which has been created.
... example pc.ondatachannel = function(ev) { console.log('data channel is created!'); ev.channel.onopen = function() { console.log('data channel is open and ready to be used.'); }; }; specifications specification status comment webrtc 1.0: real-time communication between browsersthe definition of 'rtcpeerconnection.ondatachannel' in that specification.
RTCPeerConnection.createDataChannel() - Web APIs
WebAPIRTCPeerConnectioncreateDataChannel
negotiated optional by default (false), data channels are negotiated in-band, where one side calls createdatachannel, and the other side listens to the rtcdatachannelevent event using the ondatachannel eventhandler .
... // offerer side var pc = new rtcpeerconnection(options); var channel = pc.createdatachannel("chat"); channel.onopen = function(event) { channel.send('hi you!'); } channel.onmessage = function(event) { console.log(event.data); } // answerer side var pc = new rtcpeerconnection(options); pc.ondatachannel = function(event) { var channel = event.channel;  channel.onopen = function(event) { channel.send('hi back!'); } channel.onmessage = function(event) { console.log(event.data); } } alternatively, more symmetrical out-of-band negotiation can be used, using an agreed-upon id (0 here): // both sides var pc = new rtcpeerconnection(options); var channel = pc.createdatachannel("ch...
RTCPeerConnection: datachannel event - Web APIs
WebAPIRTCPeerConnectiondatachannel event
bubbles no cancelable no interface rtcdatachannelevent event handler property ondatachannel examples this example sets up a function that handles datachannel events by gathering the information needed to communicate with the newly added rtcdatachannel and by adding event handlers for the events that occur on that channel.
... this same code can also instead use the rtcpeerconnection interface's ondatachannel event handler property, like this: pc.ondatachannel = ev => { receivechannel = ev.channel; receivechannel.onmessage = myhandlemessage; receivechannel.onopen = myhandleopen; receivechannel.onclose = myhandleclose; } specifications specification status comment webrtc 1.0: real-time communication between browsersthe definition of 'datachannel' in that specificatio...
RTCPeerConnection - Web APIs
WebAPIRTCPeerConnection
this happens whenever the aggregate state of the connection changes.ondatachannel the rtcpeerconnection.ondatachannel property is an eventhandler which specifies a function which is called when the datachannel event occurs on an rtcpeerconnection.
... also available through the ondatachannel event handler property.
Index - Web APIs
WebAPIIndex
3435 rtcpeerconnection.ondatachannel event handler, experimental, property, rtcpeerconnection, reference, webrtc, ondatachannel the rtcpeerconnection.ondatachannel property is an eventhandler which specifies a function which is called when the datachannel event occurs on an rtcpeerconnection.
RTCDataChannelEvent.channel - Web APIs
WebAPIRTCDataChannelEventchannel
pc.ondatachannel = function(event) { inbounddatachannel = event.channel; inbounddatachannel.onmessage = handleincomingmessage; inbounddatachannel.onopen = handlechannelopen; inbounddatachannel.onclose = handlechannelclose; } specifications specification status comment webrtc 1.0: real-time communication between browsersthe definition of 'rtcdatachannelevent.channel' in that ...
RTCDataChannelEvent - Web APIs
WebAPIRTCDataChannelEvent
pc.ondatachannel = function(event) { inbounddatachannel = event.channel; inbounddatachannel.onmessage = handleincomingmessage; inbounddatachannel.onopen = handlechannelopen; inbounddatachannel.onclose = handlechannelclose; } see a simple rtcdatachannel sample for another, more complete, example of how to use data channels.
A simple RTCDataChannel sample - Web APIs
WebAPIWebRTC APISimple RTCDataChannel sample
set up the remote peer remoteconnection = new rtcpeerconnection(); remoteconnection.ondatachannel = receivechannelcallback; the remote end is set up similarly, except that we don't need to explicitly create an rtcdatachannel ourselves, since we're going to be connected through the channel established above.