Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sample depends on Express 2 code #3

Open
wangbus opened this issue Sep 22, 2012 · 2 comments
Open

Sample depends on Express 2 code #3

wangbus opened this issue Sep 22, 2012 · 2 comments
Assignees

Comments

@wangbus
Copy link

wangbus commented Sep 22, 2012

The package.json points to "latest" for express which is version 3. The createServer doesn't respond with an object can be used for SSE(app).

Solution:

Easy: Specify ~2.5.11 instead of latest.
More work: Change to express 3 syntax.

@gillesdemey
Copy link

Any ideas on how to get it to work with Express 3? I can't seem to figure it out.

@trygve-lie
Copy link
Collaborator

This, modified version of the express example in this repo, works on Express 3.x:

var http              = require('http'),
    express           = require('express'),
    sse               = require('../../'),
    app               = express(),

    port              = process.argv[2] ? process.argv[2] : 8000,
    docRoot           = './public';

app.configure(function() {
  app.use(express.static(docRoot));
});

var httpServer = http.createServer(app);

var sseServer = new sse(httpServer);

sseServer.on('connection', function(client) {
  var id = setInterval(function() {
    client.send(JSON.stringify(process.memoryUsage()));
  }, 100);
  console.log('started client interval');
  client.on('close', function() {
    console.log('stopping client interval');
    clearInterval(id);
  })
});

httpServer.listen(port);

I do have some extensive documentation plus an updated example with Express 3.x which is 99.9% done laying around. I'll try to fix the remaining 0.1% and get it into the master the next couple of days. Sorry for the delay.

@ghost ghost assigned trygve-lie Dec 28, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants