Subscribe individual tabs to channels #223

Closed
werg opened this Issue Apr 14, 2012 · 4 comments

Comments

Projects
None yet
3 participants
@werg

werg commented Apr 14, 2012

Hi,
sorry to be so late to the show (didn't have the time to check out 0.3 before), but I have a feature-request, something that already bothered me in 0.2:

I would really like to be able to subscribe only individual tabs to channels.
Here's my scenario: I have an app that offers chat-rooms. Every room is represented by a channel. A user has several tabs open, all with different rooms. Why should all tabs receive all updates for all channels in this case?

A cursory survey of the source (which, oh my god, looks really, really nice and clean! that's the way source-code should be!) leaves me with the impression that I could rather easily patch on this behavior (after all, channels seem to speak directly to socketIds anyway), it would take a bit of additional work to get subscribe/unsubscribe behavior at session level to play nicely though.

What one could do is attach an extra (optional) attribute to the session, maybe 'partialChannels' which are affected by session-wide unsubscribes. Unsubscribing individual tabs might be a bit more messy, as the expected behavior would probably be that a session-wide subscription is then demoted to a partial subscription.

What do you think? Should I patch this on from the outside or would you be interested in integrating this into socketstream?

@nponeccop

This comment has been minimized.

Show comment Hide comment
@nponeccop

nponeccop Apr 16, 2012

Contributor

I think channel subscription should be per connection and not per session.

Contributor

nponeccop commented Apr 16, 2012

I think channel subscription should be per connection and not per session.

@owenb

This comment has been minimized.

Show comment Hide comment
@owenb

owenb Apr 17, 2012

I agree there is a need for this. The main problem is that socketIds are very transitory.

Should the connection go down and reconnect for any reason (server reboot, wifi problems, user hits reload by accident), you get another socketId - so the app would have to deal with this and manually resubscribe.

Ideally I think we should offer both req.session.channel.subscribe() and something like req.socket.channel.subscribe().

At the heart of this is a much bigger and broader discussion: Should individual tabs simply act as multiple interfaces to the same app, or function completely independently? Ultimately I think we should leave the decision to the app developer and provide the best tools for both approaches.

owenb commented Apr 17, 2012

I agree there is a need for this. The main problem is that socketIds are very transitory.

Should the connection go down and reconnect for any reason (server reboot, wifi problems, user hits reload by accident), you get another socketId - so the app would have to deal with this and manually resubscribe.

Ideally I think we should offer both req.session.channel.subscribe() and something like req.socket.channel.subscribe().

At the heart of this is a much bigger and broader discussion: Should individual tabs simply act as multiple interfaces to the same app, or function completely independently? Ultimately I think we should leave the decision to the app developer and provide the best tools for both approaches.

@nponeccop

This comment has been minimized.

Show comment Hide comment
@nponeccop

nponeccop Apr 17, 2012

Contributor

I think we should leave the decision to the app developer a d provide the best tools for both approaches.

I agree

Contributor

nponeccop commented Apr 17, 2012

I think we should leave the decision to the app developer a d provide the best tools for both approaches.

I agree

@owenb

This comment has been minimized.

Show comment Hide comment
@owenb

owenb Jun 5, 2012

Going to close this now. Rest assured this is an issue very much on my mind and something I am keen to support in the future.

owenb commented Jun 5, 2012

Going to close this now. Rest assured this is an issue very much on my mind and something I am keen to support in the future.

@owenb owenb closed this Jun 5, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment