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

Rooms functionality #21

Open
likerRr opened this issue Jul 5, 2017 · 1 comment
Open

Rooms functionality #21

likerRr opened this issue Jul 5, 2017 · 1 comment

Comments

@likerRr
Copy link
Owner

likerRr commented Jul 5, 2017

Add ability to group connections by rooms and send events to this group. Something like:

let sseExpress = require('./sse-express');
//...
app.get('/join-room', function(req, res) {
    res.sse.join('room-name'); // joins connection to room
    sseExpress.room.join('room-name', clientId);
});
app.get('/leave-room', sseExpress.room, function(req, res) {
    sseExpress.room.leave('room-name', clientId); // leaves connection to room
});
app.get('/messages', sseExpress(), function(req, res) {
    res.sse.toRoom('room-name', clientId, {
        event: 'message',
        data: {
          text: req.body.message,
          userId: req.body.userId
        },
        id: Date.now() + req.body.userId
      })
});
@kkafara
Copy link

kkafara commented Mar 8, 2018

I'd suggest putting it in separate library extending this one, core library should do one thing and do it well

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

2 participants