从Apache端口80提供静态内容,并在端口8080上的Socket.IO服务器上提供动态/数据内容
app =require('http').createServer(handler)。Socket.IO应用程序中不需要
Apache端口80 | ------------- | 客户| ------------ | Socket.IO端口8080
var io = require('socket.io').listen(8080);io.sockets.on('connection', function (socket) { io.sockets.emit('this', { will: 'be received by everyone'}); socket.on('clientMSG', function (from, msg) { console.log('I received a private message by ', from, ' saying ', msg); }); socket.on('disconnect', function () { sockets.emit('user disconnected'); });});
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)