Beispiel #1
0
module.exports = (function () {
  "use strict";

  var modelo = require('modelo'),
    browser = require('./browser'),
    FileIterable = require('./iterables/file');


  function File() {
    browser.ExtendedIterable.call(this);
    FileIterable.apply(this, arguments);
  }
  modelo.inherits(File, browser.ExtendedIterable, FileIterable);

  browser.File = File;

  return browser;

}());
Beispiel #2
0
  this.namespace = options.namespace;
  this.projectId = process.env.DATASTORE_PROJECT_ID || options.projectId;

  var config = {
    projectIdRequired: false,
    baseUrl: this.baseUrl_,
    customEndpoint: this.customEndpoint_,
    service: 'datastore',
    apiVersion: 'v1beta3',
    scopes: ['https://www.googleapis.com/auth/datastore']
  };

  GrpcService.call(this, config, options);
}

modelo.inherits(Datastore, DatastoreRequest, GrpcService);

/**
 * Helper function to get a Datastore Double object.
 *
 * @param {number} value - The double value.
 * @return {object}
 *
 * @example
 * var threeDouble = gcloud.datastore.double(3.0);
 */
Datastore.double = function(value) {
  return new entity.Double(value);
};

/**
   * @resource [What is Cloud IAM?]{@link https://cloud.google.com/iam/}
   *
   * @example
   * //-
   * // Get the IAM policy for your subscription.
   * //-
   * subscription.iam.getPolicy(function(err, policy) {
   *   console.log(policy);
   * });
   */
  this.iam = new IAM(pubsub, this.name);

  this.listenForEvents_();
}

modelo.inherits(Subscription, GrpcServiceObject, events.EventEmitter);

/**
 * Simplify a message from an API response to have three properties, `id`,
 * `data` and `attributes`. `data` is always converted to a string.
 *
 * @private
 */
Subscription.formatMessage_ = function(msg, encoding) {
  var innerMessage = msg.message;
  var message = {
    ackId: msg.ackId
  };

  if (innerMessage) {
    message.id = innerMessage.messageId;
Beispiel #4
0
        this.init(results[0].internalipaddress, username);
      } else {
        // TODO: Handle no results
        internals.debug('Auto discovered failed to find a bridge');
        this._events.emit('bridge.failed', 'No bridges could be found');
      }

    });
  } else {
    internals.debug('Manually intializing the bridge with IP: %s', ip);
    this.init(ip, username);
  }

}

Modelo.inherits(internals.Hue, Bridge);

/**
 * Discovers the bridges on the network
 * http://www.developers.meethue.com/documentation/hue-bridge-discovery
 *
 * @method  discover
 * @param   {String|Array} method can be a string to search via one method, or an array of search methods ['upnp', 'nupnp', 'ip']
 * @return  {Promise} will return a promise that will resolve with the discovered bridges
 */
internals.Hue.prototype.discover = function discover(method) {
  var discover = this._discover;
  internals.debug('Running discover using %s method', method || 'waterfall');
  return Promise.using(discover.search(method), function(search) {
    internals.debug('Search completed with the following results: %o', search);
    return Promise.resolve(search);
Beispiel #5
0
  var config = {
    parent: parent,
    id: name,
    methods: methods
  };

  GrpcServiceObject.call(this, config);
  events.EventEmitter.call(this);

  this.completeListeners = 0;
  this.hasActiveListeners = false;

  this.listenForEvents_();
}

modelo.inherits(GrpcOperation, GrpcServiceObject, events.EventEmitter);

/**
 * Cancel the operation.
 *
 * @param {function=} callback - The callback function.
 * @param {?error} callback.err - An error returned while making this
 *     request.
 * @param {object} callback.apiResponse - The full API response.
 */
GrpcOperation.prototype.cancel = function(callback) {
  var protoOpts = {
    service: 'Operations',
    method: 'cancelOperation'
  };
    // This means the last 00 is really the last 00000000 and
    // we need to advance the pointer a little bit.
    if (packet.subtypeLength === 1) writer.writeLong(0x00);

    // Rewrite packetLength and bytesRemaining
    writer.buffer.writeUInt32LE(writer.pointer, 4);
    writer.buffer.writeUInt32LE(writer.pointer - 20, 16);

    // We only need the useful part of the buffer
    return writer.buffer.slice(0, writer.pointer);
};

var states = require('./states');
var ClientGroup = require('./ClientGroup');

modelo.inherits(Server, EventEmitter, HookEmitter, ClientGroup);

Server.knownPackets = knownPackets;
Server.knownSubPackets = knownSubPackets;
Server.packetsByName = packetsByName;

var World = require('./World');
var entities = require('./entities');
var StateProxy = require('./StateProxy');
var Client = require('./Client');

/**
 * Starts the server listening
 *
 * @param {Function?} started A callback for when the server begins listening for connections
 * @returns {Server} this