Coder Social home page Coder Social logo

Comments (7)

peteruithoven avatar peteruithoven commented on May 18, 2024 1

I created a redis pub/sub wrapper with a callback system. This allows me to, from one instance, execute a emit on another instance and retrieve the response using a callback.
https://www.npmjs.org/package/redis-pubsubber

from socket.io-redis-adapter.

objectiveSee avatar objectiveSee commented on May 18, 2024

If you need to emit events to socket.io instances from a non-socket.io process, you should use socket.io-emitter.

from socket.io-redis-adapter.

peteruithoven avatar peteruithoven commented on May 18, 2024

Thanks I'll have a look at that, maybe there is a workaround there.
But I'm actually in the situation where I use a clustered socket.io server. Now I would like to forward a message from one client (that's for example on instance A) to a specific other client (that's for example on instance B). So all instances are socket.io servers.

from socket.io-redis-adapter.

shantanuthatte avatar shantanuthatte commented on May 18, 2024

Use rooms, and send the message to the room with the client you desire.
Every client gets its own room with a unique id. So, sending it just to the
room with the id would work.

Regards,
Shantanu Thatte
On Oct 1, 2014 4:24 PM, "Peter Uithoven" [email protected] wrote:

Thanks I'll have a look at that, maybe there is a workaround there.
But I'm actually in the situation where I use a clustered socket.io
server. Now I would like to forward a message from one client (that's for
example on instance A) to a specific other client (that's for example on
instance B). So all instances are socket.io servers.


Reply to this email directly or view it on GitHub
#30 (comment)
.

from socket.io-redis-adapter.

peteruithoven avatar peteruithoven commented on May 18, 2024

I'll try.
I'm sorry I forgot to mention that I would like to use acknowledgment callbacks. I tried putting the target client into a room with a custom name (so I don't have to store the socket.io id in a database), but then it becomes a broadcast (to possible multiple clients) and then I can't specify a acknowledgment callback. So I tried retrieving the clients from a room, so I could target them specifically, but retrieving the clients from rooms isn't possible yet (#13).

from socket.io-redis-adapter.

peteruithoven avatar peteruithoven commented on May 18, 2024

I just want to confirm that talking to a client of another socket.io server can be done by using their socket.io id as room name. It also works when you put this target client in a custom room with a fixed name and talk to that room from another socket.io server instance.
This means that socket.io-redis does support rooms, it just can't list the clients in rooms. It probably can't list the rooms that exist in other servers either.

But sadly, emitting into a room is considered broadcasting, probably because there can be multiple clients in a room, so you can't use callbacks. You'll get the following error when trying:

Callbacks are not supported when broadcasting

from socket.io-redis-adapter.

peteruithoven avatar peteruithoven commented on May 18, 2024

So I see two possible solutions:

  • Find a way to create a fake socket (so I can use existing callback code)
  • Broadcast to a room and build my own callback system, see: socketio/socket.io#1656 (comment)

from socket.io-redis-adapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.