admin管理员组文章数量:1386467
So I am a newbie at Meteor, and in Bigbluebutton 2.4, I have to make a simple message that goes to all the users in a meeting. even without the meeting criteria I still cant get them on my frontend In the code, I can subscribe to the ptzmessage and I see it in `Meteor.connection._subscriptions list on the browser
componentDidMount() {
const { onVideoItemMount, cameraId } = this.props;
console.log("subscribing")
Meteor.subscribe('ptzmessage').ready()
this.subscription = Meteor.subscribe('ptzmessage');
// Retry after 5 seconds if not ready
this.retryTimeout = setTimeout(() => {
if (!this.subscription.ready()) {
console.log("Retrying subscription...");
this.subscription = Meteor.subscribe('ptzmessage');
}
console.log(" subscription completed...");
}, 5000);
this.tracker = Tracker.autorun(() => {
console.log("Fetching messages...");
const messages = PtzMessages.find({}).fetch();
this.setState({ messages });
console.log('Received Messages:', messages);
});
this is the Api file in import/api/ptzmessage and imported in the frontend and the backend
import { Mongo } from 'meteor/mongo';
// Define PtzMessages collection
export const PtzMessages = new Mongo.Collection('ptzmessages');
if (Meteor.isServer) {
PtzMessages._ensureIndex({ meetingId: 1 });
}
this is the server code when I press button send message it adds it in the collection
import { Meteor } from 'meteor/meteor';
import { PtzMessages } from '../index.js';
Meteor.publish('ptzmessage', function () {
console.log(`Client ${this.connection.id} subscribed to ptzmessage`);
return PtzMessages.find();
});
Meteor.methods({
sendPtzMessage(message) {
console.log("#####################################################################################api hit")
PtzMessages.insert({ text: message, createdAt: new Date() }, (err, res) => {
if (err) {
console.error("Insert Error:", err);
} else {
console.log("Message inserted successfully:", res);
}
});
}
});
infact in the frontend Meteor.connection._mongo_livedata_collections.ptzmessages.find().fetch();
get me the latest messages, but I don't get them in real-time on the Tracker.
Stuff like this is done in other code that works what am I doing wrong?
本文标签: javascriptNot recieving messages on clients in MeteorStack Overflow
版权声明:本文标题:javascript - Not recieving messages on clients in Meteor - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744515765a2610150.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论