-
Notifications
You must be signed in to change notification settings - Fork 175
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
Feature request: everyone.now.exclude([clientId]).someMethod functionality #50
Comments
After further discussion a better syntax might be:
or of course the same should work for a sub-group:
Also, please understand that the group functionality is no solution to this problems. Groups are like "persistent selectors", where expensive operations need to be made to move the required users to a new group. The suggested exclude functionality would be meant for selectors that occur for a different id on every call, for example to exclude the client that called the remote method. It would obviousely not be efficient to create a whole new group just for one method and store all those references of all clients except one for every call that is made by every client. |
Personally, I see a flaw in the logic in processing a message post locally in the example. A client posting something is one procedure, and the message arrival is another. Matter of taste purely, though. Still, filtering group members is very fruitful pattern. I only do not understand why only |
@dvv, I know what you're talking about regarding the chat example. It was merely an example though. I will give you a new example that does not have this flaw. For example, say client A has a certain resource. The goal of the application is to send this resource to all clients. Because client A already has this resource, it should only be send to client B, C, .... Thus, it should not be resend to client A. I completely agree with your suggestion that a whole set of selectors would be preferable. I merely suggested the most useful one in my case. I do not know whether it'd be much more challenging to also implement these other selectors though. |
This is a good feature. Definitely a common pattern to need to exclude a certain user. @dvv I'll look into that. Indeed internally it does iterate over an array. |
Would definitely like to see bunch of methods like @dvv said and not just exclude. Thumbs Up for feature request. A proposalBut, I would go with the nomenclature we all are already familiar with, and now much popularized by jQuery selection API. e.g. everyone.now(".ferrariFans").someMethod(); // This is same as group calling. Infact .ferrariFans could be name of the group already created.
everyone.now("#anIndividualClient").someMethod(); // to pin down a single client and invoke something on it.
everyone.now("someRegularExpression").someMethod(); // whoooo ! this couldd be icing on the cake. Needless to say how powerful one could be.
everyone.now(":pair").someMethod(); // A pseudo class. Client is assumed to be already paired with another client and method is just meant for that
everyone.now(":flashsocket").someMethod(); // A pseudo class. to all the client who are connect with flashsocket as transport.
... many more Ofcourse, then it will be necessary to name clients in certain cases. Don't know if we can directly use parts of jQuery selection API and plug it into the now.js code or that would be seperate module written in C :p. JustificationAs now.js gains popularity, these patterns of various ways of managing clients would emerge and be in demand. I guess having a mechanism to address this requirement at this moment would be really great. There are many scenarios where this kind of filtering would be required. I could see many game development use cases here !! |
@samyakbhuta, personally I'd see much more use in an exclusion from all than either of the inclusion patterns you have specified. I reckon that the exclude pattern is simple and highly efficient, allowing the team to work on more important issues rather than delaying such feature and cause even longer implementation pauses as such extensive selection API would be a considerable time investment. |
Given |
@dvv, you're right -- never mind my remarks about time investment. The filter option is especially interesting. |
I just found myself including |
@tommedema, my stress is not if we would include or exclude, but have JQuery style selection. One can also use negate operator to decide if they want to exclude or include. e.g ! or ^. |
@samyakbhuta: am sorry, but what is the point of borrowing jQuery syntax in now.js deep? Given an arbitrary filtration is supported, writing a shim consisting of a couple of filtering functions which would honor jQuery style would be an easy task. |
Implemented in v0.7. You can do the following, if you really want:
That'll essentially just exclude the calling user. A bit contrived, but there are more useful applications of .filter(), of course, such as excluding folks who are additionally members of group X. |
A very common scenario is where you'd want to broadcast to all clients in a group except for the client that sent the initial message.
For example, in a chat application, when a user sends a message he does not need to know from the server that he actually sent this message. Thus, the client can add this message locally. However, the server does have to send this message to all clients except for the originating client. This is just an example.
It would make no sense to copy all clients to a new group except for that originating client, thus I propose the following exclude style:
which would work exactly the same as:
with the exception that clientId1 and clientId2 are excluded.
Thoughts?
The text was updated successfully, but these errors were encountered: