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...`);
|
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';
|
const categoryTitle = socket.joinedCategories[room] || 'UNKNOWN';
|
||||||
await socket.leave(room);
|
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) {
|
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 = [];
|
const updatedClientList = [];
|
||||||
|
|
||||||
clients.forEach((client) => {
|
clients.forEach((sid) => {
|
||||||
if (!client.isConnected || !client.user) return;
|
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({
|
updatedClientList.push({
|
||||||
user: {
|
user: {
|
||||||
username: client.user.username,
|
username: client.user.username,
|
||||||
|
|
|
@ -231,6 +231,7 @@ const app = new Vue({
|
||||||
};
|
};
|
||||||
this.gateway.connect(this.loggedInUser.token);
|
this.gateway.connect(this.loggedInUser.token);
|
||||||
this.gateway.socket.on('message', (e) => {
|
this.gateway.socket.on('message', (e) => {
|
||||||
|
//console.log('[*] [gateway] Message received', e);
|
||||||
this.processMessage(e);
|
this.processMessage(e);
|
||||||
});
|
});
|
||||||
this.gateway.socket.on('clientListUpdate', (e) => {
|
this.gateway.socket.on('clientListUpdate', (e) => {
|
||||||
|
|
Loading…
Reference in a new issue