This documents explains how this was done, and what the repercussion of this solutions are.
Sending a string
If you use the plugin so send a string with this call:
Then the plugin is directly sending the string "data" to the other side of the data channel.
Sending a non string data
If you send one of the following types:
When the remote data channel receives the string, it will change it back into a UInt8Array using the following function:
When you receive the data on the other side of the data channel, you can then use:
Temasys considered it the best available solution and does not plan on releasing a different implementation in the close future.
Sending other types of data
Sending other types of data will lead to unexpected behaviour. You data might be sent successfully, some of it might be lost or corrupted, or the plugin could even crash.
- The implementation of string sending is that same as it was before.
- You should not override the functions _Tem_ab2str nor _Tem_str2ab.
- Overriding these functions might lead to unexpected behaviours
Examples of how to use the data channel
We adapted the dataChannel sample provided by Google to work with the plugin, and implemented a second test for sending non-string elements.
Please refer to these examples if you try to implement a data channel in your own solution.
DataChannel and strings: https://github.com/Temasys/Google-WebRTC-Samples/tree/master/samples/web/content/datachannel
DataChannel and ArrayBuffers: https://github.com/Temasys/Google-WebRTC-Samples/tree/dev/samples/web/content/datachannel-arraybuffer