tutorial for Express 3.x and socket.io [closed]

2019-06-20 08:50发布

问题:

Is there a good starter tutorial combining socket.io and express using Express 3.x?

Actually a simple chat application would be great.

The less lines of code it uses the better.

回答1:

You can check any 2.x tutorial and change the way to start the server as this post explains: socket.io.js not found

2.X.X

var app = require('express').createServer();
var io = require('socket.io').listen(app);

app.listen(10000);

3.X.X

var express = require('express')
, http = require('http');

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

server.listen(10000);