There’s a couple of ways you could implement a memory only option.
The first, using pub/sub, is to use the low-level added / changed / removed DDP messages in a publish function. Here’s a quick example tracking online status of users:
// Server
Meteor.publish('onlineUsers', function () {
const onlineUsers = [];
Accounts.onLogin(details => {
if (onlineUsers.includes(details.user._id)) return
onlineUsers.push(details.user._id)
this.added('onlineUsers', details.user._id, {online: true})
});
Accounts.onLogout(details => {
if (!onlineUsers.includes(details.user._id)) return
onlineUsers.splice(onlineUsers.indexOf(details.user._id))
this.removed('onlineUsers', details.user._id)
});
this.ready()
});
// Client
const onlineUsersCollection = new Mongo.Collection('onlineUsers');
Meteor.subscribe('onlineUsers', function onReady() {
const currentlyOnline = onlineUsersCollection.find().fetch()
});
Docs here: https://docs.meteor.com/api/pubsub.html
Second, you can use a library that allows you to send your own messages across the websocket (like meteor-streams or streamy and DIY the tracking
Third, you can use meteor methods (or HTTP) and polling, push the data onto an array on the server and send a copy of the array each time you get a request:
const onlineUsers = [];
Accounts.onLogin(details => {
onlineUsers.push(details.user._id);
});
Accounts.onLogout(details => {
onlineUsers.splice(onlineUsers.indexOf(details.user._id));
});
Meteor.methods({
getOnlineUsers() {
return onlineUsers;
},
});