DanielBaulig / sioe-demo

socket.io and Express. Tying it all together. Demo Application
http://www.danielbaulig.de/socket-ioexpress/
52 stars 22 forks source link

not working... #3

Closed PaykomanVll closed 9 years ago

PaykomanVll commented 9 years ago

Hello,

i need you solution for an session based auth but your syntax is fail or too old :( I hafe your script 1 to 1 copy paste and tested... The initalitation of servers is other as my own script and your get an error by init... :(

Line #4 app = express.createServer()

get: createServer() is undefined....

my server will be init on this lines:

// Require HTTP module (to start server) and Socket.IO var http = require('http'); var io = require('socket.io'); var express = require('express'); // need on hs var port = 8080;

// Start the server var server = http.createServer(function(req, res){ // Send HTML headers and message res.writeHead(200,{ 'Content-Type': 'text/html' }); res.end( console.log('

Hello Socket Lover!

') ); }); server.listen(port);

// Create a Socket.IO instance, passing it our server var socket = io.listen(server);

// Add a connect listener socket = socket.of('/root'); // set namespace socket.on('connection', function(socket){ /* my stuff / });

DanielBaulig commented 9 years ago

This is for a very old version of Express. Try the following instead:

var express = require('express');
var app = express();