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

Socket-IO and Express/Connect #447

Closed
seflless opened this issue Oct 10, 2010 · 3 comments
Closed

Socket-IO and Express/Connect #447

seflless opened this issue Oct 10, 2010 · 3 comments

Comments

@seflless
Copy link

hi,

I've been trying to get Socket-IO to work with Express/Connect all day. Has anyone go this working?

I'm of course using the http://github.com/bnoguchi/Socket.IO-connect lib, which requires this patched version of Connect: http://github.com/bnoguchi/Connect/tree/serverAccessFromHandle. There must be an easier way. I'd like to benefit from both libs.

Thanks in advance for anyone who's got a handle on this.

@jwcooper
Copy link

This is the easiest way to use express and socket.io: http://github.com/robrighter/node-boilerplate
Follow the instructions, and you'll have a running base application with express and socket.io...it's pretty slick.

@tj
Copy link
Member

tj commented Oct 11, 2010

hmm yeah you should not need a patch to Connect.. the mailing list has quite a few people that have used Socket.IO with Express so id try that

@shripadk
Copy link

use client.listener.server.viewHelpers and expose your session in your dynamicHelpers. That way you can access session data. Store that data in a array using client.sessionId as the index.
server.js:
app.dynamicHelpers({
current_user: function(req) {
return req.session.user;
}
});
var io = io.listen(server), buffer = [];
io.on('connection', function(client){
var session = client.listener.server.viewHelpers;
buffer[client.sessionId] = session.current_user.name;
.
.
.

You are good to go :) However, i just realized that i am not able to remove the element from the array on disconnection. Doing
buffer.splice(client.sessionId, 1) does not remove the element from the array. Thats strange coz it, AFAIK, has to work!!! It works for smaller indexes though. Say if you have,
var buffer = [];
buffer[1] = 2; buffer[2] = 3; buffer[3] = 4;
buffer.splice(2,1); //This will remove the element with index 2
However,
buffer[8732620431110263] = 5;
buffer.splice(8732620431110263, 1); //This does not remove the element with index 8732620431110263 !!!!! Why is that so?

Jxck pushed a commit that referenced this issue Apr 17, 2011
for example when nested deep, if you have a
partial located at ./views/messages.jade

partial("messages");

will still work
This issue was closed.
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

4 participants