1

I'm using sailsjs sockets and I'm trying to find a way to add security to room events.

Basically I have a user collection with a 1-many relationship with a car collection.

I want to have my app listen to the create event when a user creates a new car, while making sure I'm not leaking create events by other users.

When I use Car.subscribe(req.socket) with

Car.publishCreate({
  id: 3,
  color: 'blue',
  user: 1
})

all users who are listening to the Car model room receive updates.

I know that I can specify sockets to omit with a second parameter: Car.publishCreate( values, [socketToOmit] ), but with many users, this becomes pretty heavyweight.

Is there a simple way to notify/limit "create" events to a specific user in a model room?

Jason Kulatunga
  • 5,814
  • 1
  • 26
  • 50
  • possible duplicate of [Conditional publish events](http://stackoverflow.com/questions/24360816/conditional-publish-events) – sgress454 Jul 20 '14 at 18:15

1 Answers1

0

In redis, there is a named Channel which supports subpub, you can push messages onto a named Channel ,such as ToJohn, and redirect sockets to get messages on that named Channel.

wish you luck.

fandyst
  • 2,740
  • 2
  • 14
  • 15