Sha256: d2880a3f255abc282279ae6bca7ba5ca7bc88908cf0366b7a63423faa7573b63
Contents?: true
Size: 1.3 KB
Versions: 9
Compression:
Stored size: 1.3 KB
Contents
<!DOCTYPE html> <html> <head> <title>WebSocket ...</title> <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'></script> <script> function debug(str) { $("#debug").append("<p>" + str + "</p>"); }; $(document).ready(function() { if (!("WebSocket" in window)) { alert("Sorry, WebSockets unavailable."); return; } var ws = new WebSocket("ws://localhost:9000/ws"); ws.onmessage = function(evt) { $("#msg").append("<p>" + evt.data + "</p>"); }; ws.onclose = function() { debug("socket closed"); }; ws.onopen = function() { debug("connected..."); }; $('#submit').click(function() { var nick = $('#nick').val(); var msg = $('#message').val(); ws.send(nick + ": " + msg); return false; }); }); </script> </head> <body> <form> <label>Nick</label> <input type='text' autofocus='true' id='nick' name='nick' value='anon' size='20' /><br /> <label>Message</label> <input type='text' autofocus='true' id='message' name='message' value='' size='80' /> <input type='submit' id='submit' /> </form> <div id="debug"></div> <div id="msg"></div> </body> </html>
Version data entries
9 entries across 9 versions & 1 rubygems