node.js - how to use Express 4 with Socket.io 0.9.x? -


I am an iOS developer, the objc-Socket.io library still supports socket.io 0.9.x

I use Express 4.0 with my NodesJS server:

server.js

  var Express = required Is ('express') (); Var io = Required ('socket.io'); Io.listen (express);  

But I run it in the terminal, puts an error to me:

 % node test socket. Io's `(`) means the meaning of 'http .server' as your first parameter, are you migrating from Express 2.x to 3.x? If so, see the "Socket.io compatibility" section at https://github.com/visionmedia/express/wiki/Migrating-from-2.x-to-3.x  
.

This code should do the trick:

  var express = require ('express' ); Var http = Required ('http'); Var app = express (); Var server = http.createServer (app) .listen (1337); Var io = Required ('socket.io'). Listen (server); Io.on ('connection', function (socket) {// emissions and listening to the message}}); App.get ('/', function (req, res) {// do something}};  

Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -