[英]Online/Offline Notification in Node.js like Facebook notification system
我正在Node.js中實現類似於Facebook通知系統的通知系統。 我已經看到一些使用Socket.io的實現,但我不知道它是否適合我的情況。 我想做的另一種方法是創建一個Notification模型(我使用MongoDB作為存儲),如下所示:
var Notification = new mongoose.Schema({
title: {type: String},
added: {type: Date},
accountId: {type: mongoose.Schema.ObjectId},
notificationType: {type: String},
isSeen: {type: Boolean}
});
然后,我將在我的帳戶架構中使用它:
var AccountSchema = new mongoose.Schema({
email: { type: String, unique: true },
password: { type: String },
name: {
first: { type: String },
last: { type: String },
full: {type: String}
},
notifications: [Notification]
});
然后,我將根據操作向用戶添加某些通知。 但是,我不確定這種方法是否能很好地運作。 因此,我想知道哪種方法最適合這種情況: 在線/離線通知 。
提前致謝,
您應該真正關注發布/訂閱系統以進行實時通知。
如果您遇到離線的訂戶,您可以存儲在[Notification]架構中。 一旦用戶再次連接,它可以查詢它們並確認它們看起來像是。
資源:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.