Skip to content

Joining socket room from instance that doesn't have the socket in memory. #125

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

Closed
jreeter opened this issue Aug 24, 2016 · 3 comments · Fixed by #168
Closed

Joining socket room from instance that doesn't have the socket in memory. #125

jreeter opened this issue Aug 24, 2016 · 3 comments · Fixed by #168

Comments

@jreeter
Copy link

jreeter commented Aug 24, 2016

We have a multi process socket service that is backed by a message based queue, so I can't guarantee which socket instance gets the messages. Naturally, socket.io-redis is what I am needing so I can perform emits across any instance so it can reach the client. This part works. What I am having problems with is telling socket clients to join or leave rooms across instances, is this possible?

seneca.add({role:'sockets', cmd:'leaveRoom', accountId:'*', podId:'*'}, function(args, done) {
        return seneca.actAsync({role: 'session', cmd: 'read', key: args.accountId})
        .then((session) => {
            if(session && session.socketId) {

                // I need to tell the socket with id session.socketId to leave a certain room
            }
        })
        .catch(seneca.log.error)
        .finally(() => {
            done();
        });
    });
@jreeter
Copy link
Author

jreeter commented Sep 6, 2016

+1 bump

@darrachequesne
Copy link
Member

Hi! You may be able to catch the messages sent from the underlying adapter by overriding the Socket#packet method here: https://github.com/socketio/socket.io/blob/master/lib/socket.js#L218

See https://github.com/socketio/socket.io-adapter/blob/master/index.js#L132

@infnada
Copy link

infnada commented Jan 2, 2017

Could this help? I'm still searching a "community" solution for this case:

socketio/socket.io#2458

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 a pull request may close this issue.

3 participants