129
+ − 1
+ − 2
+ − 3 <!DOCTYPE html>
+ − 4 < html >
+ − 5 < head >
+ − 6 < title > XMPP Websocket</ title >
+ − 7 < script type = "text/javascript" >
+ − 8 if ( "WebSocket" in window ) {
+ − 9 var ws = new WebSocket ( "ws://localhost:5281/xmpp-websocket" );
+ − 10 ws . onopen = function () {
+ − 11 ws . send ( "<stream:stream to='localhost' xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0'>" );
+ − 12 };
+ − 13 ws . onmessage = function ( evt ) {
+ − 14 var message = evt . data ;
+ − 15 alert ( "Received frame: " + message );
+ − 16 };
+ − 17 ws . onclose = function () {
+ − 18 alert ( "Disconnected" );
+ − 19 };
+ − 20 } else {
+ − 21 alert ( "Your browser doesn't implement WebSocket !" );
+ − 22 }
+ − 23 </ script >
+ − 24 </ head >
+ − 25 < body >
+ − 26 </ body >
+ − 27 </ html >