I'm running a node application that conditionally .uses other applications based on the subdomain of the HTTP request. The code for that is as below:
var server = http.createServer(app);
...
global.socket = io.listen(server);
...
subdomains.forEach(function (subdomain) {
var vhost = (subdomain == '_' ? '' : subdomain + '.') + domain;
app.use(express.vhost(vhost, require('./' + subdomain)));
});
Now suppose I want to use socket.io in two different subdomains. They both have access to the same socket, since it's running on the same port. Yet if I try to connect to http://sub1.domain.tld/, any broadcasts are also sent to http://sub2.domain.tld/.
Is there any way I can restrict broadcast, emit, &c. based on the subdomain of the connection?
Just to mark as "answered". As of now, it appears that there is no way to accomplish what I'm trying to do.