I've got the basic chatroom working (single page), but I'd like to generate a unique one when I browse to my URL. E.g. User browses to chatroom.com and is redirected to chatrooom.com/room1, then s/he can share that url with friends to chat with. How do I go about doing this?
You need a router, you could use backbone or my personal favorite meteor router (installed via meteorite):
mrt install router
in your client js
//In your chat query add something to localise your chat messages for your room e.g (if you're using handlebars):
Template.messages.message = function() {
//assuming messages contains your collection of chats
return messages.find({room:Session.get("room")}) //get the room name set in the router
};
And for your router (also in the client js):
Meteor.Router.add({
'/': 'home',
'/rooms/:id': function(id) {
Session.set("room",id); //set the room for the template
return "messages"; //If you're template is called messages
},
'*': 'not_found'
});
So if you were to load /rooms/lobby it would load only the messages with the room value as lobby.
More docs on meteor router here : https://github.com/tmeasday/meteor-router