English 中文(简体)
页: 1 IO on subdomains with Express.js vhost
原标题:Socket.IO on subdomains with Express.js vhost

我有两辆快车在我的服务器上运行。

一辆便衣车称为“主要用途”,另一辆是使用Socket。 IO称“备案”。

我的“主要应用程序”在“Mdomain.com”和“m-app”上运行;“socket-app”在“socket.mydomain.com”上运行。

我正在通过快车式装饰式中继器向ocket申请。

----------

var express = require( express );
var app = module.exports = express.createServer();
app.use(express.vhost( socket.mydomain , require( ./socket-app/app.js )));

app.listen(8080, function(){
  console.log("Express server listening on port %d in %s mode");
});

这部工程是罚款的,我可以看到我对8080港的停泊费。 我

然而,似乎存在着一个问题,即网上备案时间不定,在管理Socket时没有收到“升级”活动。 IO app through vhost as discussed here

So my question is how can I pipe this "upgrade" event from my main-app to my socket-app so all connected sockets can hear when someone connects & disconnects?

我曾尝试在“主要适用”范围内放弃“升级”活动,但似乎并没有奏效。

app.on( upgrade , function(req, socket) {
    socket.emit( upgrade , app);    
});

What am I missing here?

最佳回答

解决办法是设立一个Socket案件。 IO在您的根基应用中,可以在全球范围内获得您的子主要应用,然后在自己的袖珍中运行。 IO称空间以维护自治。

我刚刚建造了一个simple example,这三例聊天申请都与Socket相同。 IO在根本适用中宣布。

如果您,并遵循设立当地子域的指示,你可以看到独立于他人的聊天申请。

我将努力在清点台上写上有关明天上午如何工作的更多细节。

<>Update>

这里是一份如何分享文件。 多个领域的综合研究。

问题回答

暂无回答




相关问题
How to make Sequelize use singular table names

I have an model called User but Sequelize looks for the table USERS whenever I am trying to save in the DB. Does anyone know how to set Sequelize to use singular table names? Thanks.

What is Node.js? [closed]

I don t fully get what Node.js is all about. Maybe it s because I am mainly a web based business application developer. What is it and what is the use of it? My understanding so far is that: The ...

Clientside going serverside with node.js

I`ve been looking for a serverside language for some time, and python got my attention somewhat. But as I already know and love javascript, I now want learn to code on the server with js and node.js. ...

Can I use jQuery with Node.js?

Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?

How do I escape a string for a shell command in node?

In nodejs, the only way to execute external commands is via sys.exec(cmd). I d like to call an external command and give it data via stdin. In nodejs there does yet not appear to be a way to open a ...

热门标签