Closed tommedema closed 13 years ago
So right now if you do this, the callback you pass in will be called once for each client, in that client's this.now context.
To get the amount of clients connected you can do what you're doing now. We may add a client count feature so you can easily get the number of clients in a group.
Providing a callback (that runs once) when all callbacks have completed is easy to do, internally it would have to be a counter kind of like what you have now. The difficulty lies in the syntax. Not sure how you would pass this callback in during a remote function call on a group
@ericz, at the moment I am not doing this because I cannot get the max count. How would I achieve this functionality now?
Oh duhh. My bad you're right you don't have the max. I'll see if its easy to expose a way a count and get back to you
Ok this now exists in the master on github.
Simply do everyone.count or somegroup.count to get the number of users at the time. Make sure you are careful as its possible that the remote call does not return before the usercount changes.
This is an undocumented feature and the api for this will probably change in the future
@ericz, thanks. Should a new issue be created such as "document group.count and improve API" or do you have an internal ToDo?
Just figured that it should not be forgotten
I have an internal todo already so no issue is necessary, thanks!
On Thu, Apr 14, 2011 at 9:39 AM, tommedema reply@reply.github.com wrote:
@ericz, thanks. Should a new issue be created such as "document group.count and improve API" or do you have an internal ToDo?
Just figured that it should not be forgotten
Reply to this email directly or view it on GitHub: https://github.com/Flotype/now/issues/49#comment_1002232
510-691-3951 EECS Student at UC Berkeley http://ericzhang.com
I'm in this situation: I have an incoming stream and receive a chunk. I wish to send this chunk to all now.js clients, but need to pause the stream until all clients have received the chunk.
I can do something like this:
client:
and on the server:
But:
I'm not 100% sure, but it might be a good idea to add a callback to remote function calls for when all clients have received this method. I'm not sure of the implications and overhead involved though...