基本的なチャットルーム(単一ページ)が機能していますが、URLを参照するときに一意のチャットルームを生成したいと思います。たとえば、ユーザーがchatroom.comにアクセスし、chatrooom.com / room1にリダイレクトされると、そのURLを友達と共有してチャットできます。どうすればこれを行うことができますか?
			
			1071 次
		
1 に答える
            6        
        
		
ルーターが必要です。バックボーンまたは私のお気に入りの隕石ルーター(隕石を介してインストール)を使用できます。
mrt install router
クライアント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
};
そしてあなたのルーターのために(これもクライアント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'
});
したがって、ロードする場合は、値が。/rooms/lobbyのメッセージのみがロードされます。roomlobby
ここにmeteorルーターに関するその他のドキュメント:https ://github.com/tmeasday/meteor-router
于 2013-02-05T18:29:52.877   に答える