You are reading a single comment by @Injecteer and its replies. Click here to read the full conversation.
  • I'm facing a strange situation: after changing the code, the event listeners are not registered anymore.

    The code now looks like:

    MyClass.prototype.initialize = function () {
        var self = this;
        self.wifi.connect( self.ssid, { password:self.wlanPw }, function( err ){
          console.log( "connected? info=", self.wifi.getIP() );
          if( !err ) self.connect();
        } );
    }
    
    MyClass.prototype.connect = function () {
    	this.ws = new WS( this.serverHost, { port:8822 } );
    	this.ws.gwId = this.wifi.getIP().mac;
    	this.ws.premiseId = this.premiseId;
    	this.ws.handshake = this.handshake.bind( this.ws );
    	this.ws.on( 'open', function(){
    	  console.log( 'ws openned' );
    	} );
    	this.ws.on( 'message', this.onWsMessage );
    	this.ws.on( 'close', this.onWsClose );
    
    	console.log( "Connecting to ", this.serverHost, 8822 );
    };
    
    MyClass.prototype.onWsMessage = function( msg ) { doSomething(); };
    MyClass.prototype.onWsClose = function() { ... };
    

    in the console I see

    connected? info= {
    "ip": "192.168.0.16",
    "netmask": "255.255.255.0",
    "gw": "192.168.0.1",
    "mac": "5c:cf:7f:19:71:73"
    }
    Connecting to ec2-52-34-212-117.us-west-2.compute.amaz­onaws.com 8822

    I see also, that the WS request hits the server.

    It used to work, so now I'm banging my head trying to figure out what could possibly go wrong here...

About

Avatar for Injecteer @Injecteer started