fix messages not being broadcasted
This commit is contained in:
parent
de6a66a877
commit
35d37ea782
2 changed files with 6 additions and 6 deletions
|
@ -101,9 +101,8 @@ GatewayServer.prototype.eventSetup = function() {
|
|||
content: content,
|
||||
_id: uuid.v4()
|
||||
};
|
||||
|
||||
socket.broadcast.to(category._id).emit('message', messageObject);
|
||||
socket.emit('message', messageObject);
|
||||
|
||||
this._gateway.in(category._id).emit('message', messageObject);
|
||||
});
|
||||
|
||||
socket.on('subscribe', async (categories) => {
|
||||
|
@ -114,9 +113,9 @@ GatewayServer.prototype.eventSetup = function() {
|
|||
const category = await Category.findById(v);
|
||||
if (category && category.title && category._id) {
|
||||
if (!socket.joinedCategories) socket.joinedCategories = {};
|
||||
if (socket.joinedCategories[category._id]) continue;
|
||||
socket.joinedCategories[category._id] = category.title;
|
||||
socket.join(category._id);
|
||||
if (socket.joinedCategories[v]) continue;
|
||||
socket.joinedCategories[v] = category.title;
|
||||
await socket.join(v);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -222,6 +222,7 @@ const app = new Vue({
|
|||
};
|
||||
this.gateway.connect(this.loggedInUser.token);
|
||||
this.gateway.socket.on('message', (e) => {
|
||||
console.log(e);
|
||||
this.processMessage(e);
|
||||
});
|
||||
},
|
||||
|
|
Reference in a new issue