3

I am creating a node webkit application in which I want to implement audio-chat.I have implemented the same with EasyRTC and it's working fine. I have a sails server for my application which is running in the port 1337 and the audio-chat that I have implemented is running in 1338. The problem that I am facing now is that, whenever a user logs in, the connection to my audio-chat controller is established. And when the user logs out, it is disconnected. After the case, if a user logs in again, it is throwing an error:

Developer error: attempt to connect when already connected to socket server, even though I have disconnected the server.

For connecting:

$scope.connect = function() {
  easyrtc.enableVideo(false);
  easyrtc.enableVideoReceive(false);
  easyrtc.setRoomOccupantListener($scope.convertListToButtons);
  easyrtc.setSocketUrl(io.sails.chat_url, {
        'connect timeout': 10000,
        'force new connection': true
  });
  easyrtc.initMediaSource(
        function() { // success callback
              easyrtc.connect("easyrtc.audioOnly", $scope.loginSuccess, $scope.loginFailure);
              easyrtc.setUsername($rootScope.currentUser.user.id);                                                                  },
    function(errorCode, errmesg) {
          easyrtc.showError(errorCode, errmesg);
    } // failure callback
  );
}

For disconnecting:

$scope.disconnect = function() {
     easyrtc.disconnect();
}

I ran the application in debug mode, in EasyRTC library file, self.webSocket is undefined when the user logs out and logs in. Still it's giving the above error.

Can anyone help me figure out what the problem actually is?

Thanks in advance.

Travis Webb
  • 14,688
  • 7
  • 55
  • 109
DivyaMenon
  • 311
  • 4
  • 19

0 Answers0