我想在Rocket Chat中创建一个新的订阅,例如stream-all-messages
,与stream-room-messages
中的已经存在于文档中的订阅相同。
我正在使用DDP监听器来测试它,以下是我正在尝试的示例。
// Subscribe to a message stream from a channel or group
console.log("Attempting to subscribe to the Group/Channel now.\n");
ddpClient.subscribe("stream-room-messages", [RoomId, false], function() {
console.log(ddpClient.collections);
console.log("Subscription Complete.\n");
// Display the stream on console so we can see its working
console.log("\nStarting live-stream of messages.:\n");
ddpClient.on("message", function(msg) {
console.log("Subscription Msg: " + msg);
});
});
上面的示例有效,因为stream-room-messages
已经存在但是当我尝试执行以下操作时会引发错误,即
Subscription Msg: {"msg":"nosub","id":"2","error":{"isClientSafe":true,"error":404,"reason":"Subscription 'stream-only-messages' not found","message":"Subscription 'stream-all-messages' not found [404]","errorType":"Meteor.Error"}}
我称之为
// Subscribe to a message stream from a channel or group
console.log("Attempting to subscribe to the Group/Channel now.\n");
ddpClient.subscribe("stream-all-messages", [RoomId, false], function() {
console.log(ddpClient.collections);
console.log("Subscription Complete.\n");
// Display the stream on console so we can see its working
console.log("\nStarting live-stream of messages.:\n");
ddpClient.on("message", function(msg) {
console.log("Subscription Msg: " + msg);
});
});
请帮我解答如何添加新订阅。