File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -58,31 +58,33 @@ module.exports = class Connection extends EventEmitter {
5858
5959 socket = this . socket = new WebSocket ( ws_addr ) ; // jshint ignore:line
6060
61- socket . onopen = _ . bind ( function ( ) {
61+ socket . onopen = function ( ) {
6262 that . onSocketFullyConnected ( ) ;
63- } ) ;
63+ } ;
6464 socket . onclose = function ( ) {
6565 that . onSocketClose ( ) ;
6666 } ;
6767 socket . onmessage = function ( event ) {
6868 that . onSocketMessage ( event . data ) ;
6969 } ;
70- socket . onopen = function ( ) {
71- that . onSocketFullyConnected ( ) ;
70+ socket . onerror = function ( err ) {
71+ that . debugOut ( 'socketError() ' + err . message ) ;
72+ that . last_socket_error = err ;
7273 } ;
7374 }
7475
7576 // Called when the socket is connected and ready to start sending/receiving data.
7677 onSocketFullyConnected ( ) {
7778 this . debugOut ( 'socketFullyConnected()' ) ;
79+ this . last_socket_error = null ;
7880 this . connected = true ;
7981 this . emit ( 'open' ) ;
8082 }
8183
8284 onSocketClose ( ) {
8385 this . debugOut ( 'socketClose()' ) ;
8486 this . connected = false ;
85- this . emit ( 'close' ) ;
87+ this . emit ( 'close' , this . last_socket_error ? this . last_socket_error : false ) ;
8688 }
8789
8890 onSocketMessage ( data ) {
You can’t perform that action at this time.
0 commit comments