我之前设置了我的应用程序,以便它可以正常工作。我最近改变了几件事的顺序,现在它坏了。我希望有人知道使用 socket.io(在 heroku 上)设置节点/快速应用程序的最佳方法。我想我错过了一些东西,因为我似乎无法让它工作。
这是我当前的 app.js 中断:
var express = require('express'),
app = express.createServer(express.logger()),
io = require('socket.io'),
routes = require('./routes'),
chatroom = require('./routes/chatroom'),
http = require('http'),
path = require('path');
io.configure(function () {
io.set("transports", ["xhr-polling"]);
io.set("polling duration", 10);
});
var socket = io.listen(app);
app.configure(function(){
app.set('port', process.env.PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
});
app.get('/', routes.index);
app.get('/room/:chatroom', chatroom.create_room);
app.get('/privateroom/:chatroom', chatroom.create_private_room);
var port = process.env.PORT || 3000;
app.listen(port);