June 2024
Beginner to intermediate
268 pages
6h 26m
English
Just like we did to power the chat, let’s write another symmetric data channel whose only purpose will be to exchange feature information between two peers.
Start off by creating an addFeaturesChannel() function that resembles the addChatChannel() function you created in Setting Up the Text-Chat Data Channel. The features channel will be negotiated and established with an id of 110. Inside the function, add an onopen event whose callback immediately sends along a JSON version of $self.features to the remote peer:
| | function addFeaturesChannel(peer) { |
| | peer.featuresChannel = |
| | peer.connection.createDataChannel('features', |
| | { negotiated: true, id: 110 }); |
| | |
| | peer.featuresChannel.onopen ... |
Read now
Unlock full access