-
Notifications
You must be signed in to change notification settings - Fork 27
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
Unsure how to subscribe to a publish per user #16
Comments
I just moved over to this package from arunoda's and am having the same problem. Not sure if this is possible since the allow rules use the event name and there's no userId at that point |
I use the userId as the event name as a workaround and specify the real event name in the parameters. streamer.emit(Meteor.userId(), { eventName: 'post', postId: post._id })
streamer.allowRead(function allowRead(userId) {
return this.userId === userId
}) |
Ok, thanks @maxnowack , I see now. We are setting the rule for all streams in streamer. @mitar, I'm not sure if this answers your question but it does mine. Now I need to figure out how to only allow the server to emit. (Edit: nevermind, I just noticed this: "The default permission deny all comunication, you should define a new permission!") |
Yea, I would love it there would be a simpler 1:1 way to move from arunoda's package to this. Using userId as a event name seems hackish. Would it be possible for a malicious user claim that they should receive some other event name with another userId, if they know that userId? |
@mitar I'm not sure about your use case, but for me it ended up being very close. The security defaults to deny, and for the read rule, using userId is not hackish because the rule is defined on the server, and when you emit from the server you get to use Meteor.userId() |
Looking at the code it seems you are right. The above approach would work and works well. The only issue I have now is that it creates one publish endpoint for each user. So for every even name a publish endpoint is created ( |
I would simply like to keep the normal subscribe/publish, but just to send messages from publish function to a particular client which is subscribing (instead of keeping the state on the server for publish).
From looking at this package, I am unsure how to do so that each client would have its own set of messages being generated and coming from server. It seems this is more suitable when multiple clients share a set of messages. But how could I do it so that each client (or subscription) has its own set of messages, no other client can see?
The text was updated successfully, but these errors were encountered: