12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <!DOCTYPE html>
- <html>
- <head>
- <title>WebSocket Example</title>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/3.1.3/socket.io.js"></script>
- <script type="text/javascript">
- // var socket = io.connect('https://' + document.domain + ':' + location.port);
- var socket = io.connect('https://' + "127.0.0.1" + ':' + 5000);
-
-
- function sendMessage() {
- var message = document.getElementById('message').value;
- socket.emit('message', message);
- }
-
- socket.on('connect', function () {
- console.log('Connected to the server');
- // socket.emit('message', "run_fn");
- });
-
- socket.on('response', function (data) {
- console.log('Server says: ' + data);
- });
-
- function function_name(argument) {
- // body...
- }
-
- clog=console.log
- function rec_q_to_tab(data_str,a,b,c,d){
- clog({that:this},arguments)
- var data = JSON.parse(data_str)
-
- clog(data)
- lines = data.file_content.split("\n")
- proc_data = {arr:[]}
- for (line of lines){
- if (!line){
- clog("NOT LINE",line)
- continue
- }
- // clog()
- proc_data.arr.push(JSON.parse(line))
- }
-
-
- }
- socket.on('q_to_tab_q', rec_q_to_tab)
-
-
- </script>
- </head>
- <body>
- <h1>WebSocket Example</h1>
- <input type="text" id="message" placeholder="Type a message">
- <button onclick="sendMessage()">Send</button>
- </body>
- </html>
|