简体   繁体   中英

Direct Message to online users in MeteorJS

In a chat application, I want to be able to send messages to two users directly if there are online. I'm using mizzao:user-status to detect if they are online or not. Let's imagine 2 users Tom and Sam. So both are online and using the application. Now when Tom sends a mesaage to Sam and vice-versa, I want to send the message directly to Sam without first storing it in MongoDB through Web Sockets. Meteor Streams seemed like a viable option, but here's the problem. Let's say 1000 people are using the app all at once. Now some people can send only their friends messages. How do I ensure security so Sam can't edit some source files and read everyone's messages going through the wire.

Thanks.

When I was doing my chat app I didn't use any streams, since Meteor is reactive I just stored all messages in a Collection, and find() was returning data, no packages were needed. If I wanted to send data to users, I simply fetch() users who are online(with mizzao:user-status aswell), and then sent message to all of them using .forEach

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM