There is a line in the Javascript cometd chat client distributed in 3.1 that I don't understand

41 views Asked by At

My question is about the _metaConnect function in chat.js. Here's the function:

   function _metaConnect(message) {
        if (!$scope.joined) {
            $scope.connected = false;
            _connectionClosed();
        } else {
            var wasConnected = $scope.connected;
            $scope.connected = message.successful === true;
            if (!wasConnected && $scope.connected) {
                _connectionEstablished();
            } else if (wasConnected && !$scope.connected) {
                _connectionBroken();
            }
        }
    }

Specifically, what does the line

$scope.connected = message.successful === true; 

accomplish?

1

There are 1 answers

0
Alexandru Severin On

$scope.connected gets the value of message.successful === true.

message.successful === true has the value true if message.successful has the value true or false if message.successful has any other value.