--- miscJava/Test3/WebContent/WebsockTest.html 2014/02/10 21:54:54 2106 +++ miscJava/Test3/WebContent/WebsockTest.html 2014/02/11 08:33:52 2107 @@ -25,7 +25,7 @@ } socket.onmessage = function(msg){ - append(msg); //Awesome! + append(msg.data); //Awesome! } socket.onclose = function(){ @@ -42,12 +42,31 @@ socket.send(txt); + $("#txt").val(""); + } catch(exception) { append(exception); } }); + $(document).keypress(function(e) { + if(e.which == 13) { + try { + var txt = $("#txt").val(); + append(txt); + + socket.send(txt); + $("#txt").val(""); + + } catch(exception) { + append(exception); + } + } + }); + }); + + @@ -55,7 +74,7 @@

Websocket test chat

- +