added js file
This commit is contained in:
parent
8019fc8d31
commit
7bc165d7a0
1 changed files with 12 additions and 0 deletions
12
public/javascripts/socket.js
Normal file
12
public/javascripts/socket.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
$(document).ready(function(){
|
||||
function debug(str){ $("#debug").append("<p>" + str); };
|
||||
|
||||
ws = new WebSocket("ws://localhost:8080/");
|
||||
ws.onmessage = function(evt) { $(".msg").prepend("<p>"+evt.data+"</p>"); };
|
||||
ws.onclose = function() { debug("socket closed"); };
|
||||
ws.onopen = function() {
|
||||
debug("connected...");
|
||||
ws.send("hello server");
|
||||
ws.send("hello again");
|
||||
};
|
||||
});
|
||||
Loading…
Reference in a new issue