Question

I create a server using nowjs. How can I serve clients grouped under an URL.

It's a wague way of putting the question. I ll give an example.

I run my server(with nowjs) in mysite.com which contains many chat rooms.

Users can join one of the chat rooms and start chatting. Real time sync happens - all handled by nowjs.

Now coming to my problem, I'm not able to differentiate between the chat rooms. Whatever chatroom user joins, since I'm using the everyone object, every user gets a message (independent of which chat room he is in).

Was it helpful?

Solution

use a group object.

I solved this issue by using

everyone.now.distributeMessage = function(message,groupname){
    group = nowjs.getGroup(groupname);
    group.now.receiveMessage(this.now.name, message, groupname);
}

everyone has access to that function, and by passing the groupname, only those who are members of that group get the message.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top