express.io icon indicating copy to clipboard operation
express.io copied to clipboard

Documentation does not appear to be updated for Express 4.2

Open jrgleason opened this issue 11 years ago • 3 comments

I am trying to figure out how to broadcast from an existing web application. The new version of a generated express application looks as follows...

app.js

app.get('/route', function(req, res){
  req.io.broadcast('new visitor');
});

No dice this gives me a 404 so I try to move things into the routes\index.route file...

var express = require('express');
var router = express.Router();
...
router.get('/route', function(req, res){
  req.io.broadcast('new visitor');
});

Still no dice this gives me an undefined exception. So what is the proper way for setting this up in Express 4? Currently does work in the app.js...

app.http().io();
app.io.route('ready', function(req) {
    req.io.emit('talk', {
        message: 'io event from an io route on the server'
    })
})

jrgleason avatar Aug 29 '14 23:08 jrgleason

+1 - this looks super useful, but def need Express 4+ support.

pretentiousgit avatar Nov 12 '14 15:11 pretentiousgit

+1 - agreed. I've seen in other issue comments that techpines is working on Express 4 support as recently as July. Looking forward to that!

mike-feldmeier avatar Nov 15 '14 20:11 mike-feldmeier

Yeah broadcast() wasn't working for me either, had to use emit(). Was it just renamed? The last time the broadcast example was modified was in 2012.

dmyers avatar Jun 15 '15 19:06 dmyers