Show More
@@ -27,7 +27,7 b' var IPython = (function (IPython) {' | |||||
27 | } else if (typeof(MozWebSocket) !== 'undefined') { |
|
27 | } else if (typeof(MozWebSocket) !== 'undefined') { | |
28 | this.WebSocket = MozWebSocket |
|
28 | this.WebSocket = MozWebSocket | |
29 | } else { |
|
29 | } else { | |
30 | alert('Your browser does not have WebSocket support, please try Chrome, Safari or Firefox 6. Firefox 4 and 5 are also supported by you have to enable WebSockets in about:config.'); |
|
30 | alert('Your browser does not have WebSocket support, please try Chrome, Safari or Firefox β₯ 6. Firefox 4 and 5 are also supported by you have to enable WebSockets in about:config.'); | |
31 | }; |
|
31 | }; | |
32 | }; |
|
32 | }; | |
33 |
|
33 | |||
@@ -89,6 +89,7 b' var IPython = (function (IPython) {' | |||||
89 |
|
89 | |||
90 |
|
90 | |||
91 | Kernel.prototype.start_channels = function () { |
|
91 | Kernel.prototype.start_channels = function () { | |
|
92 | var that = this; | |||
92 | this.stop_channels(); |
|
93 | this.stop_channels(); | |
93 | var ws_url = this.ws_url + this.kernel_url; |
|
94 | var ws_url = this.ws_url + this.kernel_url; | |
94 | console.log("Starting WS:", ws_url); |
|
95 | console.log("Starting WS:", ws_url); | |
@@ -97,17 +98,50 b' var IPython = (function (IPython) {' | |||||
97 | send_cookie = function(){ |
|
98 | send_cookie = function(){ | |
98 | this.send(document.cookie); |
|
99 | this.send(document.cookie); | |
99 | } |
|
100 | } | |
|
101 | var already_called_onclose = false; // only alert once | |||
|
102 | ws_closed_early = function(evt){ | |||
|
103 | if (already_called_onclose){ | |||
|
104 | return; | |||
|
105 | } | |||
|
106 | already_called_onclose = true; | |||
|
107 | if ( ! evt.wasClean ){ | |||
|
108 | alert("Websocket connection to " + ws_url + " could not be established." + | |||
|
109 | " You will not be able to run code." + | |||
|
110 | " Your browser may not be compatible with the websocket version in the server," + | |||
|
111 | " or if the url does not look right, there could be an error in the" + | |||
|
112 | " server's configuration."); | |||
|
113 | } | |||
|
114 | } | |||
|
115 | ws_closed_late = function(evt){ | |||
|
116 | if (already_called_onclose){ | |||
|
117 | return; | |||
|
118 | } | |||
|
119 | already_called_onclose = true; | |||
|
120 | if ( ! evt.wasClean ){ | |||
|
121 | alert("Websocket connection has closed unexpectedly." + | |||
|
122 | " The kernel will no longer be responsive."); | |||
|
123 | } | |||
|
124 | } | |||
100 | this.shell_channel.onopen = send_cookie; |
|
125 | this.shell_channel.onopen = send_cookie; | |
|
126 | this.shell_channel.onclose = ws_closed_early; | |||
101 | this.iopub_channel.onopen = send_cookie; |
|
127 | this.iopub_channel.onopen = send_cookie; | |
|
128 | this.iopub_channel.onclose = ws_closed_early; | |||
|
129 | // switch from early-close to late-close message after 1s | |||
|
130 | setTimeout(function(){ | |||
|
131 | that.shell_channel.onclose = ws_closed_late; | |||
|
132 | that.iopub_channel.onclose = ws_closed_late; | |||
|
133 | }, 1000); | |||
102 | }; |
|
134 | }; | |
103 |
|
135 | |||
104 |
|
136 | |||
105 | Kernel.prototype.stop_channels = function () { |
|
137 | Kernel.prototype.stop_channels = function () { | |
106 | if (this.shell_channel !== null) { |
|
138 | if (this.shell_channel !== null) { | |
|
139 | this.shell_channel.onclose = function (evt) {null}; | |||
107 | this.shell_channel.close(); |
|
140 | this.shell_channel.close(); | |
108 | this.shell_channel = null; |
|
141 | this.shell_channel = null; | |
109 | }; |
|
142 | }; | |
110 | if (this.iopub_channel !== null) { |
|
143 | if (this.iopub_channel !== null) { | |
|
144 | this.iopub_channel.onclose = function (evt) {null}; | |||
111 | this.iopub_channel.close(); |
|
145 | this.iopub_channel.close(); | |
112 | this.iopub_channel = null; |
|
146 | this.iopub_channel = null; | |
113 | }; |
|
147 | }; |
General Comments 0
You need to be logged in to leave comments.
Login now