Download pool/shard009/JavaScript/0056350_websockets.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 610 Bytes
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard009/JavaScript/0056350_websockets.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard009/JavaScript/0056350_websockets.js
-
curl -L -o 0056350_websockets.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard009/JavaScript/0056350_websockets.js
610 Bytes
| class IO { | |
| connect(){ | |
| let baseURL = location.origin || location.protocol + "//" + location.host; | |
| this.socket = io.connect(baseURL); | |
| this.socket.on("connect", () => { | |
| console.log('CONNECTED!'); | |
| }); | |
| this.socket.on("disconnect", () => { | |
| console.log('DISCONNECTED!'); | |
| }); | |
| this.attachEvents(); | |
| } | |
| attachEvents(){ | |
| this.socket.on('state', state => window.app.setState(state)); | |
| this.socket.on('frame', state => window.app.onFrame(state)); | |
| } | |
| emit(event, data){ | |
| this.socket.emit(event, data) | |
| } | |
| } | |
| const instance = new IO(); | |
| export default instance; | |