Flotype / now

NowJS makes it easy to build real-time web apps using JavaScript
http://www.nowjs.com
MIT License
1.91k stars 175 forks source link

Pass references to now clients rather than clientId strings on 'connected' event #82

Closed tommedema closed 13 years ago

tommedema commented 13 years ago

The connected event returns the clientId string of a client. I am not sure why you've decided to do this, but it'd make much more sense to make it return the actual client rather than it's id. Especially since there is no way to efficiently get a client reference from a client id.

If one still wants the id, he could just use client.user.clientId.

This way, clients can be stored for future use and the developer can implement his own selection mechanics etc.

ericz commented 13 years ago

Hi tom,

Do you mean on the server?

The connected event should already be passing in the full now and user object, not just the clientId.

Eric

tommedema commented 13 years ago

@ericz,

Indeed I am talking about the server side.

What you are saying is different from the documentation, I quote:

.on

Every group receives two events connect and disconnect. Connect is triggered when a user is added to the group. Disconnect is triggered when a user is removed from the group. These event handlers are called with one parameter, the this.user.clientId of the user that has connected or disconnected. Additionally you can also access that users this.now object (and also this.user.clientId).

everyone.on('connect', function(clientId){ //this.now.setup(); });

everyone.on('disconnect', function(clientId){ //this.now.destruct(); });

ericz commented 13 years ago

Hi tom,

I believe this issue is caused by outdated documentation

tommedema commented 13 years ago

@ericz, alright.

On a related note, it would help if the documentation was maintained on github so that we can create pull requests for it.

Also, I wanted to ask, since you use an internal versioning system, is there any point in making pull requests or are we building on outdated code?

sridatta commented 13 years ago

@tommedema: Documentation is available here https://github.com/Flotype/now/tree/master/doc/public . Everything on github is the latest working code we have internally. Think of it like a "nightly" release. So pull requests on the docs or the code itself are much appreciated.

ericz commented 13 years ago

@tommedema

Definitely make pull requests! Everything in github (including the docs) are masters, and the latest code we have.