FAQ
Hey there everyone!

I have two environments: development and testing on the same server using
different virtual hosts. What I am trying to achieve is to have one node
server instance running and serving specific socket.io events depending on
from which vhost client connects. I do not want to interfere with testers
while developing. Of course I could run two instances on different ports
but I want to make it as universal as possible.

This is what I've achieved so far:

./app.js:

var express = require('express');
var app = express();
var http = require('http');
var server = http.createServer(app);

// globally served socket.io
global.io = require('socket.io').listen(server);

app.use(express.vhost('dev.vhost', require('./subdomains/dev.vhost').app));
app.use(express.vhost('testing.vhost',
require('./subdomains/testing.vhost').app));

server.listen(10081);

./subdomains/dev.vhost.js:

var express = require('express');
var app = express();

require('./socket/presentation.dev.io');

module.exports.app = app;

./subdomains/testing.vhost.js:

var express = require('express');
var app = express();

require('./socket/presentation.testing.io');

module.exports.app = app;
./socket/presentation.dev.io.js:

module.exports = function() {
global.io.sockets.on('connection', function(socket) {
// here goes my event definitions
});
}();

The file ./socket/presentation.testing.io.js looks more less the same as
the one above but with different event definitions.

After running app and calling some event from the browser every event is
fired twice from every definition file (that is: twice from dev and twice
from testing).

Is there a way to achieve this? I'm pretty new to node.js and will
appreciate for any hints and help.

--
Job Board: http://jobs.nodejs.org/
Posting guidelines: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to nodejs@googlegroups.com
To unsubscribe from this group, send email to
nodejs+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupnodejs @
categoriesnodejs
postedOct 11, '12 at 10:23a
activeOct 11, '12 at 10:23a
posts1
users1
websitenodejs.org
irc#node.js

1 user in discussion

Paweł Lenart: 1 post

People

Translate

site design / logo © 2022 Grokbase