Establishing an RTCDataChannel connection
At the time of writing this chapter, the RTCDataChannel implementations are not completely stable and are not inter operable between the different mainstream browsers. However, the RTCDataChannel API has been designed to be almost identical to the WebSocket API when it is being used, so the general code and application logic we have defined previously should be able to be easily migrated to the RTCDataChannel API when it is ready.
The primary difference is that the WebSocket API uses a new WebSocket()
based constructor, but the RTCDataChannel API uses a peer_connection.createDataChannel()
based constructor.
However, after the offer/answer flow is completed, the RTCDataChannel event model is almost identical to the WebSocket API.