Filter messages by presens at client
How to filter messages to a client by the models present on that client? Can this be done in a secure and efficient way?
I haven't come up with a solution for that yet. There's an "Account/room-specific events" item on the TODO list in the README which is intended to address this issue.
If you'd like to take a stab at implementing it I'd love your thoughts. Feel free to post ideas on this issue about how we could go about that and we'll discuss!
I wonder if there'd be too much overhead if we just sent messages specifically to each client instead of using broadcast?
I guess it depends on the spread of objects on the different clients. I imagine the most common situation to be a sort of inverse relationship where there are many objects shared by just a few clients each (objects "owned" by some users and changed by them), and very few objects shared by many clients or all clients (status / informational objects, mostly just read by users). Does this sound realistic to you?
That's a good observation. There are probably a spectrum of use cases that will have different needs.
I wonder if the client initializer could take an optional second parameter that looks like this:
{
namespaces: ['foo', 'bar']
}
And then models on that page created with that mixin publish events with an added namespace property that the server side looks for and only broadcasts to those rooms.
Ah, maybe doing it explicitly is smarter actually... But I think that needs to happen on the server side some way for security reasons. Then the question is, can an object only exist in one namespace at a time?
Maybe a simple way to do it, would be to allow models to implement (on the server side) a method allow_read(socket) and another allow_write(socket) (Maybe even a property-level access control). That way a model author could control, using the authentication mechanisms of the app, who, rather than which client, can do what with an object.
That doesn't really handle client-only models though...
As you can see I'm clearly just brainstorming :)