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

Question on wildcards #67

Open
newhouse opened this issue Feb 9, 2018 · 2 comments
Open

Question on wildcards #67

newhouse opened this issue Feb 9, 2018 · 2 comments

Comments

@newhouse
Copy link

newhouse commented Feb 9, 2018

In my app, Users have different "roles" within an Organization. I will want to send some messages to Users/connections of all "roles", while other messages should only be sent to Users/connections with a "role" that's >= to a specific role.

When Users connect, I'm adding them to a room that is a combination of their Organization ID + their role within it, e.g. <orgId>:<role>, e.g. ORG1234:admin.

I have 2 questions:

  1. In this scenario, is there a way to send a message to all Users on an Org, regardless of their role? I would think something like primus.in('ORG1234:*').except(<filter_rooms>).send('update', data) would work, but it does not appear to work. It seems like things work in the opposite direction: a User/connection must join room ORG1234:* and a call like primus.in('ORG1234:admin').except(<filter_rooms>).send('update', data) would reach them. This seems backwards to me. Is this the case or am I missing something?

  2. (This is less expected to work, but along the same vein:) Let's say that I change the string of admin to a value like 1, so in my above example a User would connect to ORG1234:1. Is there a way to send messages to Users/connections that are in <=2 for the "role" part? E.g. primus.in('ORG1234:<=2').except(<filter_rooms>).send('update', data)? Or do I have to create all the room IDs into an array and use them like primus.in(['ORG1234:1', 'ORG1234:2']).except(<filter_rooms>).send('update', data)?

Thanks for any help!

@newhouse
Copy link
Author

@newhouse
Copy link
Author

I've gone ahead and made my own adapter to support the behavior I was looking for:
primus-rooms-reverse-wildcard-adapter

Hopefully others may find this useful.

I will leave this open so that others may find it more easily, but feel free to close if you wish of course. Thank you for this library/package, and for having enough foresight and documentation to make what I wanted to so possible without much difficulty!

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

1 participant