Closed ghost closed 8 years ago
I'm not sure I follow. The terminal.html
file is a file you create and within it, you call the WebSocket()
constructor. Let me know if the following question helps.
Just to make things clear, here are the steps to send data from the server to the browser via websockets:
1.- First download gwsocket
$ wget http://tar.gwsocket.io/gwsocket-0.1.tar.gz
$ tar -xzvf gwsocket-0.1.tar.gz
$ cd gwsocket-0.1/
$ ./configure
$ make # make install
2.- Start the websocket server
$ gwsocket &
3.- Send data from the server to the browser
$ tail -f /var/log/apache2/access.log > /tmp/wspipein.fifo
4.- Then create an html file that connects to the server (make sure you are pointing to the right IP/host where the gwsocket server is running and the port is open):
<!DOCTYPE html>
<html lang="en">
<script>
window.onload = function() {
function $(selector) {
return document.querySelector(selector);
}
var socket = new WebSocket('ws://localhost:7890');
socket.onopen = function(event) {
$('#messages').innerHTML = 'Connected<br>';
};
socket.onmessage = function(event) {
$('#messages').innerHTML += event.data + '<br>';
};
socket.onclose = function(event) {
$('#messages').innerHTML = 'Disconnected ' + event.reason;
};
};
</script>
<div id="page-wrapper">
<pre id="messages">Connecting...</pre>
</div>
5.- Open the html file and you should see your data from the server in the browser.
Ok, did not understand what the terminal.html file.
Thank you, BR
Closing this. Feel free to reopen it if needed.
Hi,
I have no problem with the collection, but does not work
lynx response is:
lynx: Start file could not be found or is not text/html or text/plain Exiting...