Skip to content

Question on wildcards #67

@newhouse

Description

@newhouse

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions