code: function(msg) {
          if (json_rpc.isSystemError(msg)) {
              if (json_rpc.isRedirect(msg)) {
                  var cb = function(err, newUrl) {
                      if (err) {
                          that.close(err);
                      } else {
                          currentUrl = newUrl;
                          resetWebSocket();
                      }
                  };
                  options.newURL(msg, cb);
              } else if (json_rpc.isNotAuthenticated(msg)) {
                  var cb0 = function(err, token) {
                      if (err) {
                          options.log(err);
                          that.close(err);
                      } else {
                          options.token = token;
                          // do not change url until authenticated
                          resetWebSocket();
                      }
                  };
                  //options.log('Not authenticated' + JSON.stringify(msg));
                  options.newToken(msg, cb0);
              } else if (json_rpc.isErrorRecoverable(msg) &&
                         (numRetries < options.maxRetries)) {
                  numRetries = numRetries + 1;
                  setTimeout(function() {
                      currentUrl = url; // original url
                      resetWebSocket();
                  }, options.retryTimeoutMsec);
              } else {
                  // Non-recoverable error
                  options.log(msg);
                  var err = new Error('Non-recoverable error');
                  err['msg'] = msg;
                  that.close(err);
              }
              return true;
          } else if (json_rpc.isAppReply(msg)){
              return Object.keys(queues)
                  .some(function(x) {
                      return queues[x].processAppReply(webSocket, msg);
                  });
          } else {
              return false;
          }
      }
docs: Handles a CA message. We have the following cases:
  
  1) No error -> route to appropriate queue.
  2) Application error -> route to appropriate queue.
  3) System error
  3-a) Redirect -> new WebSocket url + retry
  3-b) Security -> new token + retry
  3-c) Recoverable -> wait for timeout + retry
  3-d) Non-Recoverable -> close session/log error