Skip to content

Instantly share code, notes, and snippets.

@3rd-Eden
Created July 11, 2011 07:48
Show Gist options
  • Select an option

  • Save 3rd-Eden/1075441 to your computer and use it in GitHub Desktop.

Select an option

Save 3rd-Eden/1075441 to your computer and use it in GitHub Desktop.
Debug statement
/**
* Manages connections to hosts.
*
* @param {String} uri
* @Param {Boolean} force creation of new socket (defaults to false)
* @api public
*/
io.connect = function (host, details) {
var uri = io.util.parseUri(host)
, uuri
, socket;
if ('undefined' != typeof document) {
uri.protocol = uri.protocol || document.location.protocol.slice(0, -1);
uri.host = uri.host || document.domain;
uri.port = uri.port || document.location.port;
}
{{
// confirm that the uri is correctly parsed
io.log.debug('uri', uri);
}}
uuri = io.util.uniqueUri(uri);
var options = {
host: uri.host
, secure: uri.protocol == 'https'
, port: uri.port || 80
};
io.util.merge(options, details);
if (options['force new connection'] || !io.sockets[uuri]) {
socket = new io.Socket(options);
}
if (!options['force new connection'] && socket) {
io.sockets[uuri] = socket;
}
socket = socket || io.sockets[uuri];
// if path is different from '' or /
return socket.of(uri.path.length > 1 ? uri.path : '');
};
@dvv
Copy link

dvv commented Jul 11, 2011

i understand that (or whatever instead of <%, including mustache-style {{). the point was to possibly make internal static server smarter to support templating

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment