Download pool/shard011/JavaScript/0068986_rtc-text-chat.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 861 Bytes
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard011/JavaScript/0068986_rtc-text-chat.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard011/JavaScript/0068986_rtc-text-chat.js
-
curl -L -o 0068986_rtc-text-chat.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard011/JavaScript/0068986_rtc-text-chat.js
861 Bytes
| // Set RTC options. | |
| var rtcOpts = { | |
| room: 'test-data', | |
| signaller: 'https://switchboard.rtc.io', | |
| capture: false | |
| }; | |
| // call RTC module | |
| var rtc = RTC(rtcOpts); | |
| // A contenteditable element to show our messages | |
| var messages = document.getElementById('messages'); | |
| // Bind to events happening on the data channel | |
| function bindDataChannelEvents(id, channel, attributes, connection) { | |
| // Receive message | |
| channel.onmessage = function (evt) { | |
| messages.innerHTML = evt.data; | |
| }; | |
| // Send message | |
| messages.onkeyup = function () { | |
| channel.send(this.innerHTML); | |
| }; | |
| } | |
| // Start working with the established session | |
| function init(session) { | |
| session.createDataChannel('chat', { | |
| ordered: true, | |
| maxRetransmits: 12 | |
| }); | |
| session.on('channel:opened:chat', bindDataChannelEvents); | |
| } | |
| // Detect when RTC has established a session | |
| rtc.on('ready', init); | |