Código Javascript:
Ver original
// let's invite Firefox to the party. if (window.MozWebSocket) { window.WebSocket = window.MozWebSocket; } var chat = document.getElementById('chat'); var form = chat.form; var conn = new WebSocket('ws://node.remysharp.com:8001'); conn.onopen = function () { //Conexion abierta }; conn.onmessage = function (event) { var message = event.data; if (!(/^\d+$/).test(message)) { alert("Mensaje recibido" + message); } }; conn.onclose = function (event) { //Conexión cerrada }; addEvent(form, 'submit', function (event) { event.preventDefault(); conn.send(JSON.stringify(chat.value)); });