Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 748
Michael Moeller Avatar asked Jan 11 '13 14:01

Michael Moeller


People also ask

Can you use Socket.IO with express?

Socket.IO can be used based on the Express server just as easily as it can run on a standard Node HTTP server. In this section, we will fire the Express server and ensure that it can talk to the client side via Socket.IO.

How do I make my Socket.IO secure?

Setting the socket to be secured is done by: setting the secure flag - as you wrote ({secure: true}) OR by using https protocol when creating the server (instead of http) - which will set the secure flag to be true automatically.


1 Answers

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);
like image 129
Riwels Avatar answered Sep 28 '22 08:09

Riwels