code: function (type, args, callback) {
  
                  var result = function (result) {
                      return {result: result, type: type, args: args};
                  };
  
                  var error = function (error) {
                      //$log.error("$riffle error", {type: type, arguments: args, error: error});
                      return $q.reject({error: error, type: type, args: args});
                  };
  
                  // Only execute the action callback once we have an established session
                  var action = sessionPromise.then(function () {
                      return callback();
                  });
  
                  var chain = [result, error];
  
                  // Apply interceptors
                  angular.forEach(reversedInterceptors, function (interceptor) {
                      if (interceptor[type + 'Response'] || interceptor[type + 'ResponseError']) {
                          chain.push(interceptor[type + 'Response'], interceptor[type + 'ResponseError']);
                      }
                  });
  
                  // We only want to return the actually result or error, not the entire information object
                  chain.push(
                      function (response) {
                          return response.result;
                      }, function (response) {
                          return $q.reject(response.error);
                      }
                  );
  
                  while (chain.length) {
                      var resolved = chain.shift();
                      var rejected = chain.shift();
  
                      action = action.then(resolved, rejected);
                  }
  
                  return action;
              }
docs: /*
  Wraps WAMP actions, so that when they're called, the defined interceptors get called before the result is returned
  
  @param type
  @param args
  @param callback
  @returns {*}