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

Channels/selective reception? Constants? #6

Closed kcorey closed 13 years ago

kcorey commented 13 years ago

Hi All,

I can see how nowjs could easily be used to create a chat room. Talk about simple!

Context: I'm a complete node.js newbie. This is my first exposure to it, and perhaps that's where my confusion arises.

I don't see how to limit the recipients of a message. If you're building a web app, you usually don't want all your messages to go to every person. In fact, I'd go so far as to say that would be the norm: you want most messages to go to a single client, or at times a selection of clients.

I don't understand enough about the internals to see how to iterate over the clients and only send a message to client 'x', or send a message to clients that have some property (like belonging to a particular account).

Further, is there a way to make constants in the now pocket? I'd like to be able to set a value on the server, and for the client to be able to read it, but not to modify it.

Thanks,

-Ken

chadlung commented 13 years ago

Ken,

Not sure if this is what your looking for but in the Best Practices section they talk about implementing "rooms". http://nowjs.com/bestpractices

kcorey commented 13 years ago

Perfect! Thanks!

Yes, that was exactly what I was looking for. I could have sworn I'd gone through all the documents on-site. I guess not!

-Ken

sridatta commented 13 years ago

To answer the second part of your question, Javascript doesn't support constants natively so it would be hard to implement constants in the now namespace without an additional layer of syntax/complexity.