forked from hippoz/brainlet
hopefully fix user list
This commit is contained in:
parent
5b34130ef4
commit
7bebf6d471
2 changed files with 11 additions and 5 deletions
|
@ -129,7 +129,8 @@ GatewayServer.prototype.eventSetup = function() {
|
|||
|
||||
console.log(`[*] [gateway] User ${socket.user.username} subscribed to room ${v} (${category.title}), sending updated user list to all members of that room...`);
|
||||
|
||||
this._gateway.in(v).emit('clientListUpdate', await this._generateClientListUpdateObject(v, category.title));
|
||||
const upd = await this._generateClientListUpdateObject(v, category.title);
|
||||
this._gateway.in(v).emit('clientListUpdate', upd);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -144,7 +145,8 @@ GatewayServer.prototype.eventSetup = function() {
|
|||
const categoryTitle = socket.joinedCategories[room] || 'UNKNOWN';
|
||||
await socket.leave(room);
|
||||
|
||||
socket.in(room).emit('clientListUpdate', await this._generateClientListUpdateObject(room, categoryTitle));
|
||||
const upd = await this._generateClientListUpdateObject(room, categoryTitle);
|
||||
socket.in(room).emit('clientListUpdate', upd);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -152,11 +154,14 @@ GatewayServer.prototype.eventSetup = function() {
|
|||
};
|
||||
|
||||
GatewayServer.prototype._getSocketsInRoom = async function(room) {
|
||||
const clients = this._gateway.in(room).sockets;
|
||||
// NOTE: I have no idea why i have to do this dumb thing, why can't socket io just let you simply get the sockets from a room? idk
|
||||
// There kinda was a way in the previous version, but they want to change the api for the worse each version, i'm guessing
|
||||
const clients = await this._gateway.in(room).allSockets();
|
||||
const updatedClientList = [];
|
||||
|
||||
clients.forEach((client) => {
|
||||
if (!client.isConnected || !client.user) return;
|
||||
clients.forEach((sid) => {
|
||||
const client = this._gateway.sockets.get(sid); // lol they also used dumb ass maps for the socket list, can you fucking not?
|
||||
if (!client || !client.isConnected || !client.user) return;
|
||||
updatedClientList.push({
|
||||
user: {
|
||||
username: client.user.username,
|
||||
|
|
|
@ -231,6 +231,7 @@ const app = new Vue({
|
|||
};
|
||||
this.gateway.connect(this.loggedInUser.token);
|
||||
this.gateway.socket.on('message', (e) => {
|
||||
//console.log('[*] [gateway] Message received', e);
|
||||
this.processMessage(e);
|
||||
});
|
||||
this.gateway.socket.on('clientListUpdate', (e) => {
|
||||
|
|
Loading…
Reference in a new issue