@ -110,36 +110,11 @@ var IPython = (function (IPython) {
} ;
Kernel . prototype . _websocket _closed = function ( ws _url , early ) {
var msg ;
var parent _item = $ ( 'body' ) ;
if ( early ) {
msg = "Websocket connection to " + ws _url + " could not be established." +
" You will NOT be able to run code." +
" Your browser may not be compatible with the websocket version in the server," +
" or if the url does not look right, there could be an error in the" +
" server's configuration." ;
} else {
IPython . notification _area . widget ( 'kernel' ) . set _message ( 'Reconnecting Websockets' , 1000 ) ;
this . start _channels ( ) ;
return ;
}
var dialog = $ ( '<div/>' ) ;
dialog . html ( msg ) ;
parent _item . append ( dialog ) ;
dialog . dialog ( {
resizable : false ,
modal : true ,
title : "Websocket closed" ,
closeText : "" ,
close : function ( event , ui ) { $ ( this ) . dialog ( 'destroy' ) . remove ( ) ; } ,
buttons : {
"OK" : function ( ) {
$ ( this ) . dialog ( 'close' ) ;
}
}
} ) ;
Kernel . prototype . _websocket _closed = function ( ws _url , early ) {
this . stop _channels ( ) ;
$ ( [ IPython . events ] ) . trigger ( 'websocket_closed.Kernel' ,
{ ws _url : ws _url , kernel : this , early : early }
) ;
} ;
/ * *
@ -152,7 +127,7 @@ var IPython = (function (IPython) {
var that = this ;
this . stop _channels ( ) ;
var ws _url = this . ws _url + this . kernel _url ;
console . log ( "Starting W S:", ws _url ) ;
console . log ( "Starting W eb Sockets :", ws _url ) ;
this . shell _channel = new this . WebSocket ( ws _url + "/shell" ) ;
this . iopub _channel = new this . WebSocket ( ws _url + "/iopub" ) ;
send _cookie = function ( ) {
@ -182,9 +157,13 @@ var IPython = (function (IPython) {
this . iopub _channel . onopen = send _cookie ;
this . iopub _channel . onclose = ws _closed _early ;
// switch from early-close to late-close message after 1s
setTimeout ( function ( ) {
that . shell _channel . onclose = ws _closed _late ;
that . iopub _channel . onclose = ws _closed _late ;
setTimeout ( function ( ) {
if ( that . shell _channel !== null ) {
that . shell _channel . onclose = ws _closed _late ;
}
if ( that . iopub _channel !== null ) {
that . iopub _channel . onclose = ws _closed _late ;
}
} , 1000 ) ;
} ;