forked from hippoz/brainlet
fix messages not being broadcasted
This commit is contained in:
parent
de6a66a877
commit
35d37ea782
2 changed files with 6 additions and 6 deletions
|
@ -102,8 +102,7 @@ GatewayServer.prototype.eventSetup = function() {
|
|||
_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);
|
||||
});
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue