Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | clean up debugging lines, reformat code blocks for readability |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
4f6fadd830bea3ef5a62089da81d703b |
User & Date: | stever 2013-01-17 13:42:03.945 |
Context
2013-01-18
| ||
15:30 | reformat demo to reflect the concept of rendering the page view for MVC style apps check-in: ea0ef51845 user: stever tags: trunk | |
2013-01-17
| ||
13:42 | clean up debugging lines, reformat code blocks for readability check-in: 4f6fadd830 user: stever tags: trunk | |
13:41 | disable bg polling loop after upgrading connectin to WebSockets check-in: 9da8d541a8 user: stever tags: trunk | |
Changes
Changes to widgets/wtk.js.
︙ | ︙ | |||
13 14 15 16 17 18 19 | init : function(sessionid) { wtk.sessionid = sessionid; wtk.conntype = "init"; wtk.widgets['obj0'] = document.getElementById('obj0'); if ('WebSocket' in window){ | | < < > < < < < | < < | | | > > > | | < < < | > > | > > > | | 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | init : function(sessionid) { wtk.sessionid = sessionid; wtk.conntype = "init"; wtk.widgets['obj0'] = document.getElementById('obj0'); if ('WebSocket' in window){ /* WebSocket is supported. Proceed with server connection*/ //create the uri to the ws controller on server var loc = window.location, ws_uri; if (loc.protocol === "https:") { ws_uri = "wss:"; } else { ws_uri = "ws:"; } ws_uri += "//" + loc.host; ws_uri += "/wsctrl"; ws_uri += "?sessionid=" + sessionid; wtk.connection = new WebSocket(ws_uri); wtk.connection.onopen = function(){ /*Send a small message to the console once the connection is established */ console.log('Connection open!'); }; wtk.connection.onclose = function(){ console.log('Connection closed'); if (wtk.conntype != "websocket") { setTimeout(wtk.poller,100); } else { wtk.init(); }; }; wtk.connection.onerror = function(error){ console.log('Error detected: ' + error); }; wtk.connection.onmessage = function(e){ var server_message = e.data; eval(server_message); wtk.conntype = "websocket"; }; $.ajax({type:'GET', url:'wtkpoll.html?sessionid='+sessionid, dataType:'script', complete: function() {console.log("ws_init");}, error: function(jqXHR, textStatus, errorThrown) { alert("Websocket connection interrupted\nPress OK to reconnect."); console.log('ajax error '+textStatus+' '+errorThrown); setTimeout(location.reload(1),200);} }); } else { /*WebSockets are not supported. Fallback to long-polling */ setTimeout(wtk.poller,100); }; }, poller : function() {$.ajax({type:'GET', url:'wtkpoll.html?sessionid='+wtk.sessionid, dataType:'script', complete: function() {setTimeout(wtk.poller,100);}, error: function(jqXHR, textStatus, errorThrown) { alert("Server connection interrupted\nPress OK to reconnect."); console.log('ajax error '+textStatus+' '+errorThrown); setTimeout(location.reload(1),200);} }); }, sendto : function(msg) { if (wtk.conntype != "websocket") { $.get('wtkcb.html?sessionid='+wtk.sessionid, {cmd : msg}); } else { wtk.connection.send(msg); } }, /* * Generic widget creation; each widget is an HTML element of a certain type, and is given an * id by the wtk code on the server side which is used to uniquely identify it. */ |
︙ | ︙ |