MCPcopy Create free account
hub / github.com/ReactJSResources/react-webpack-babel / lookup

Function lookup

public/bundle.js:665–690  ·  view source on GitHub ↗

* Looks up an existing `Manager` for multiplexing. * If the user summons: * * `io('http://localhost/a');` * `io('http://localhost/b');` * * We reuse the existing instance based on same scheme/port/host, * and we initialize sockets for each namespace. * * @api public

(uri, opts)

Source from the content-addressed store, hash-verified

663 */
664
665 function lookup(uri, opts) {
666 if (typeof uri == 'object') {
667 opts = uri;
668 uri = undefined;
669 }
670
671 opts = opts || {};
672
673 var parsed = url(uri);
674 var source = parsed.source;
675 var id = parsed.id;
676 var io;
677
678 if (opts.forceNew || opts['force new connection'] || false === opts.multiplex) {
679 debug('ignoring socket cache for %s', source);
680 io = Manager(source, opts);
681 } else {
682 if (!cache[id]) {
683 debug('new io instance for %s', source);
684 cache[id] = Manager(source, opts);
685 }
686 io = cache[id];
687 }
688
689 return io.socket(parsed.path);
690 }
691
692 /**
693 * Protocol version.

Callers

nothing calls this directly

Calls 3

urlFunction · 0.85
debugFunction · 0.85
ManagerFunction · 0.85

Tested by

no test coverage detected