Creates a lifx client
@extends EventEmitter
550914
function Client() {
  EventEmitter.call(this);

  this.debug = false;
  this.socket = dgram.createSocket('udp4');
  this.isSocketBound = false;
  this.devices = {};
  this.port = null;
  this.messagesQueue = [];
  this.sendTimer = null;
  this.discoveryTimer = null;
  this.discoveryPacketSequence = 0;
  this.messageHandlers = [{
    type: 'stateService',
    callback: this.processDiscoveryPacket.bind(this)
  }, {
    type: 'stateLabel',
    callback: this.processLabelPacket.bind(this)
  }, {
    type: 'stateLight',
    callback: this.processLabelPacket.bind(this)
  }];
  this.sequenceNumber = 0;
  this.lightOfflineTolerance = 3;
  this.messageHandlerTimeout = 45000; // 45 sec
  this.resendPacketDelay = 150;
  this.resendMaxTimes = 5;
  this.source = utils.getRandomHexString(8);
  this.broadcastAddress = '255.255.255.255';
}
758223
function EventEmitter(isAsync) {
        if (isAsync === void 0) { isAsync = false; }
        var _this = _super.call(this) || this;
        _this.__isAsync = isAsync;
        return _this;
    }
324656
function Client(svc, opts) {
  opts = opts || {};
  events.EventEmitter.call(this);

  // We have to suffix all client properties to be safe, since the message
  // names aren't prefixed with clients (unlike servers).
  this._svc$ = svc;
  this._channels$ = []; // Active channels.
  this._fns$ = []; // Middleware functions.

  this._buffering$ = !!opts.buffering;
  this._cache$ = opts.cache || {}; // For backwards compatibility.
  this._policy$ = opts.channelPolicy;
  this._strict$ = !!opts.strictTypes;
  this._timeout$ = utils.getOption(opts, 'timeout', 10000);

  if (opts.remoteProtocols) {
    insertRemoteProtocols(this._cache$, opts.remoteProtocols, svc, true);
  }

  this._svc$.messages.forEach(function (msg) {
    this[msg.name] = this._createMessageHandler$(msg);
  }, this);
}
138706
@VisibleForTesting
  ClientCallTracer newClientCallTracer(
      TagContext parentCtx, String fullMethodName) {
    return new ClientCallTracer(this, parentCtx, fullMethodName);
  }
49141
function MessageEmitter(ptcl, opts) {
  opts = opts || {};
  events.EventEmitter.call(this);

  this._ptcl = ptcl;
  this._strict = !!opts.strictErrors;
  this._endWritable = !!utils.getOption(opts, 'endWritable', true);
  this._timeout = utils.getOption(opts, 'timeout', 10000);
  this._prefix = normalizedPrefix(opts.scope);

  this._cache = opts.cache || {};
  var fgpt = opts.serverFingerprint;
  var adapter;
  if (fgpt) {
    adapter = this._cache[fgpt];
  }
  if (!adapter) {
    // This might happen even if the server fingerprint option was set, in
    // cases where the cache doesn't contain the corresponding adapter.
    fgpt = ptcl.getFingerprint();
    adapter = this._cache[fgpt] = new Adapter(ptcl, ptcl, fgpt);
  }
  this._adapter = adapter;

  this._registry = new Registry(this, PREFIX_LENGTH);
  this._destroyed = false;
  this._interrupted = false;
  this.once('_eot', function (pending) { this.emit('eot', pending); });
}
969056
function(host, port, options) {
    EventEmitter.call(this);

    // we consider this situation is using zookeeper
    if(typeof host === "object") {
        options = host;
        host = port = undefined;
    }

    options = options || {};

    // using zookeeper will ignore `host` and `port`
    if(options.zookeeper) {
        host = port = undefined;

        this.zookeeperOptions = options.zookeeper || {};
        this.zookeeperOptions.connectString = this.zookeeperOptions.connectString || "127.0.0.1:2181";
        this.zookeeperOptions.root = this.zookeeperOptions.root || "/illyria";
        this.zookeeperOptions.prefix = this.zookeeperOptions.prefix || "/HB_";

        if(this.zookeeperOptions.connectString instanceof Array) {
            this.zookeeperOptions.connectString = this.zookeeperOptions.connectString.join(",");
        }

        if(!this.zookeeperOptions.root.startsWith("/")) {
            this.zookeeperOptions.root = "/" + this.zookeeperOptions.root;
        }

        if(!this.zookeeperOptions.prefix.startsWith("/")) {
            this.zookeeperOptions.prefix = "/" + this.zookeeperOptions.prefix;
        }

    }

    this.options = options;
    this.socket = new ISocket(options);
    this.status = "NOT_CONNECTED";

    this.port = port;
    this.host = host;

    this.runTimeout = options.runTimeout || 10000;
    this.msgId = 0;

    this.socket.addListener("error", this.emit.bind(this, "error"));
    this.socket.addListener("close", this.emit.bind(this, "close"));
    this.socket.addListener("tryReconnect", this.emit.bind(this, "tryReconnect"));
    this.socket.addListener("connected", this.emit.bind(this, "connected"));
    
    var self = this;
    this.on("connected", function() {
        self.status = "CONNECTED";
    });
    this.on("tryReconnect", function() {
        self.status = "RECONNECTING";
    });
    this.on("close", function(hadError) {
        if(hadError) {
            if(!process.env.ZK_NO_WARN) console.warn("Illyria client closed with an error.");
        }

        self.status = "DISCONNECTED";
    });
    
    this.on("error", function() {});
}
92193
function eventListenerHub(emitter, eventName) {
  var self = object.create(eventListenerHub.prototype);

  self.emitter = emitter;
  self.eventName = eventName;
  self.handlers = [];
  self.defaultHandlerFn = null;

  return self;
}
1011944
function (emitter, eventPrefix) {
        var self = this,
            oldEmit = emitter.emit;

        eventPrefix = eventPrefix || '';

        emitter.emit = function (name, data) {
            oldEmit.apply(emitter, arguments);
            self.send(eventPrefix + name, data);
        };
        return this;
    }
251570
private void createProxyJsMethod(Builder componentExposedTypeBuilder,
      ExecutableElement originalMethod, String proxyMethodName) {
    Emit emitAnnotation = originalMethod.getAnnotation(Emit.class);

    MethodSpec.Builder proxyMethodBuilder = MethodSpec
        .methodBuilder(proxyMethodName)
        .addModifiers(Modifier.PUBLIC)
        .addAnnotation(JsMethod.class)
        .addAnnotation(getUnusableByJSAnnotation())
        .returns(ClassName.get(originalMethod.getReturnType()));

    originalMethod
        .getParameters()
        .forEach(parameter -> proxyMethodBuilder.addParameter(TypeName.get(parameter.asType()),
            parameter.getSimpleName().toString()));

    String methodCallParameters = getSuperMethodCallParameters(originalMethod);
    boolean hasReturnValue = !"void".equals(originalMethod.getReturnType().toString());
    if (hasReturnValue) {
      proxyMethodBuilder.addStatement("$T result = super.$L($L)",
          originalMethod.getReturnType(),
          originalMethod.getSimpleName().toString(),
          methodCallParameters);
    } else {
      proxyMethodBuilder.addStatement("super.$L($L)",
          originalMethod.getSimpleName().toString(),
          methodCallParameters);
    }

    if (emitAnnotation != null) {
      addEmitEventCall(originalMethod, proxyMethodBuilder, methodCallParameters);
    }

    if (hasReturnValue) {
      proxyMethodBuilder.addStatement("return result");
    }

    componentExposedTypeBuilder.addMethod(proxyMethodBuilder.build());
  }
1254353
function(opts) {
  EventEmitter.call(this);

  opts = opts || {};
  this.maxLength = opts.maxLength || DEFAULT_MAX_LENGTH;

  this.offset = 0;
  this.left = 0;
  this.length = 0;
  this.buf = null;

  this.state = ST_LENGTH;
}
323381
function subscribeToEvents() {
    const socket = _socket.get(this);

    function onEventApiError(error) {
        dbg('Event API connection error: ' + JSON.stringify(error));
    }

    socket.on('pong', (latency) => {
        dbg(`Event API latency: ${latency} ms`);
    });
    socket.on('connect_error', onEventApiError);
    socket.on('error', onEventApiError);
    socket.on('disconnect', onEventApiError);
    socket.on('reconnect_error', onEventApiError);
    socket.on('reconnect_failed', () => {
        onEventApiError('Reconnecting to the Event API failed');
    });

    socket.on('new_receipt', receiptJSON => {
        const receipt = Receipt.from(receiptJSON, _provider.get(this));
        _eventEmitter.get(this).emit(EventNames.newReceipt, receipt);
    });
}
713809
void createImpl() throws SocketException {
        if (impl == null)
            setImpl();
        try {
            impl.create(true);
            created = true;
        } catch (IOException e) {
            throw new SocketException(e.getMessage());
        }
    }
951919
private void createProxyListener() throws SIResourceException
  {
    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.entry(tc, "createProxyListener");

    // Create the proxy listener instance
    _proxyListener = new NeighbourProxyListener(_neighbours, this);

    /*
     * Now we can create our asynchronous consumer to listen on      
     * SYSTEM.MENAME.PROXY.QUEUE  Queue for receiving subscription
     * updates   
     */
    // 169897.1 modified parameters
    try
    {
      _proxyAsyncConsumer =
        _messageProcessor
          .getSystemConnection()
          .createSystemConsumerSession(
            _messageProcessor.getProxyHandlerDestAddr(), // destination name
            null, //Destination filter
            null, // SelectionCriteria - discriminator and selector
            Reliability.ASSURED_PERSISTENT, // reliability
            false, // enable read ahead
            false,
            null,
            false);

      // 169897.1 modified parameters

      _proxyAsyncConsumer.registerAsynchConsumerCallback(
        _proxyListener,
        0, 0, 1,
        null);

      _proxyAsyncConsumer.start(false);
    }
    catch (SIException e)
    {
      FFDCFilter.processException(
        e,
        "com.ibm.ws.sib.processor.proxyhandler.MultiMEProxyHandler.createProxyListener",
        "1:1271:1.96",
        this);
        
      SibTr.exception(tc, e);
      
      if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled()) 
        SibTr.exit(tc, "createProxyListener", "SIResourceException");
        
      // The Exceptions should already be NLS'd
      throw new SIResourceException(e);
    }

    if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
      SibTr.exit(tc, "createProxyListener");
  }
901585
function loggerEmitter(opts) {

  if (!(this instanceof loggerEmitter)) return new loggerEmitter(opts); // new is optional
  events.EventEmitter.call(this);
  opts = opts || {};
  var logger = this;

  logger.noConsole   = opts.noConsole || false;
  logger.noErrors    = opts.noErrors  || false;
  logger.log         = log;
  logger.log.logger  = logger;
  logger.log.inspect = inspect;

  function log(x) {
    var msg;
    if (util.isError(x)) {
      msg = x.stack || x.message;
      if (!logger.noErrors) {
        logger.emit('error', x); // throws if no listener
      }
      else {
        logger.emit('log', msg);
      }
    }
    else {
      msg = util.format.apply(logger, arguments);
      logger.emit('log', msg);
    }

    if (!logger.noConsole) {
      console.log(msg);
    }

    return msg;
  }

  function inspect() { return 'logger-emitter'; }
}
931978
function createPlatformFactory(parentPlatformFactory, name, providers) {
    if (providers === void 0) { providers = []; }
    var desc = "Platform: " + name;
    var marker = new InjectionToken(desc);
    return function (extraProviders) {
        if (extraProviders === void 0) { extraProviders = []; }
        var platform = getPlatform();
        if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
            if (parentPlatformFactory) {
                parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
            }
            else {
                var injectedProviders = providers.concat(extraProviders).concat({ provide: marker, useValue: true });
                createPlatform(Injector.create({ providers: injectedProviders, name: desc }));
            }
        }
        return assertPlatform(marker);
    };
}
746387
protected JestClient createJestClient(Map<String, String> config, String indexName, String defaultIndexName) {
        String host = config.get("client.host"); //$NON-NLS-1$
        String port = config.get("client.port"); //$NON-NLS-1$
        String protocol = config.get("client.protocol"); //$NON-NLS-1$
        String initialize = config.get("client.initialize"); //$NON-NLS-1$

        if (initialize == null) {
            initialize = "true"; //$NON-NLS-1$
        }

        if (StringUtils.isBlank(host)) {
            throw new RuntimeException("Missing client.host configuration for ESRegistry."); //$NON-NLS-1$
        }
        if (StringUtils.isBlank(port)) {
            throw new RuntimeException("Missing client.port configuration for ESRegistry."); //$NON-NLS-1$
        }
        if (StringUtils.isBlank(protocol)) {
            protocol = "http"; //$NON-NLS-1$
        }
        
        String clientKey = "jest:" + host + ':' + port + '/' + indexName; //$NON-NLS-1$
        synchronized (clients) {
            if (clients.containsKey(clientKey)) {
                return clients.get(clientKey);
            } else {
                StringBuilder builder = new StringBuilder();
                builder.append(protocol);
                builder.append("://"); //$NON-NLS-1$
                builder.append(host);
                builder.append(":"); //$NON-NLS-1$
                builder.append(String.valueOf(port));
                String connectionUrl = builder.toString();

                JestClientFactory factory = new JestClientFactory();
                Builder httpClientConfig = new HttpClientConfig.Builder(connectionUrl);
                updateHttpConfig(httpClientConfig, config);
                factory.setHttpClientConfig(httpClientConfig.build());
                updateJestClientFactory(factory, config);
                
                JestClient client = factory.getObject();
                clients.put(clientKey, client);
                if ("true".equals(initialize)) { //$NON-NLS-1$
                    initializeClient(client, indexName, defaultIndexName);
                }
                return client;
            }
        }
    }
1185830
function FederationServer(bus, options) {
  events.EventEmitter.call(this);
  this.bus = bus;
  this.logger = bus.logger.withTag(bus.id + ':fedserver');
  this._options(options);
}