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

Share the Express session with Socket.IO, if it exists #90

Closed
wants to merge 1 commit into from

Conversation

timshadel
Copy link
Contributor

Based on the following article. Read the comments, too.
http://www.danielbaulig.de/socket-ioexpress/

This lets regular requests that hit Express actions emit messages back to clients over all socket.io connections they've established (with the same Express session id).

This is great for handling some work asynchronously in Node (like file parsing) by sending back a response immediately, then sending updates to the browser as events occur during your long task (like 'finished parsing', or 'error parsing').

@timshadel
Copy link
Contributor Author

Sorry. I'm not sure what you're pointing out. Did you add something, or did you notice that it exists already? Perhaps if you link to a line in the GitHub source that'd be easiest for me to understand.

[link to a line in the GitHub source](https://github.com/mauricemach/zappa/blob/master/src/zappa.coffee#L114)

Thanks!

@timshadel
Copy link
Contributor Author

Rebased this onto 0.3.1. Should pull cleanly now.

@timshadel
Copy link
Contributor Author

Hmm.. Maybe configuring client-side use of namespacing is a cleaner way to do this:

<script>
var me = io.connect('http://localhost/my-username-or-session-id');

me.on('connect', function () {
  me.emit('hi!');
});
</script>

Let me play around with that idea before you go and put all these new session references in there...I think the less that Zappa can think about the presence or absence of session the better.

@timshadel
Copy link
Contributor Author

@mauricemach - No good. I've tried a few different approaches to starting and using the socket. There are workarounds for some cases, but I just can't find a good workaround for some others -- I need my normal controller functions to be able to @emit messages to the user's "room". So, the commit still stands as is.

@mansona
Copy link

mansona commented Mar 20, 2012

has this progressed in the last 5 months? has this been solved in a different way?

@shimaore
Copy link
Contributor

FWIW we're trying to address this in zappajs#32 ; it'd be great to have some use cases so that we can validate we are providing what is needed (I already took into account @timshadel 's original description).

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

Successfully merging this pull request may close these issues.

None yet

3 participants