为表达3教程。x和socket . io

时间:2022-08-22 16:27:53

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

有没有好的入门教程结合套接字。io和express 3.x?

Actually a simple chat application would be great.

实际上,一个简单的聊天应用程序就会很棒。

The less lines of code it uses the better.

它使用的代码行越少越好。

1 个解决方案

#1


4  

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教程并更改启动服务器的方式,如本文所述:socket.com .io。js未找到

2.X.X

2. x.x

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

app.listen(10000);

3.X.X

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);

#1


4  

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教程并更改启动服务器的方式,如本文所述:socket.com .io。js未找到

2.X.X

2. x.x

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

app.listen(10000);

3.X.X

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);