1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-27 21:05:53 +00:00
* Added: Socket debugging information, including if the client is connected, latency, ping, etc.
* Changed: Make the text for profile rules more clear about what happens if you have multiple rules for a profile.
This commit is contained in:
SirStendec 2020-02-10 19:43:35 -05:00
parent e0d2eb8d81
commit aedfcecc14
6 changed files with 404 additions and 2 deletions

View file

@ -25,6 +25,15 @@ export default class SocketClient extends Module {
this.inject('settings');
this.settings.addUI('socket.info', {
path: 'Debugging > Socket >> Info @{"sort": -1000}',
force_seen: true,
no_filter: true,
component: 'socket-info',
getSocket: () => this,
});
this.settings.add('socket.use-cluster', {
default: 'Production',
@ -412,6 +421,7 @@ export default class SocketClient extends Module {
this._socket = null;
this._state = State.DISCONNECTED;
this.emit(':disconnected');
}
@ -445,6 +455,8 @@ export default class SocketClient extends Module {
this.log.warn('Local time differs from server time by more than 5 minutes.');
}
}
this.emit(':pong');
}
@ -476,6 +488,8 @@ export default class SocketClient extends Module {
send(command, ...args) {
if ( args.length === 1 )
args = args[0];
else if ( ! args.length )
args = undefined;
if ( ! this.connected )
this._pending.push([command, args]);
@ -487,6 +501,8 @@ export default class SocketClient extends Module {
call(command, ...args) {
if ( args.length === 1 )
args = args[0];
else if ( ! args.length )
args = undefined;
return new Promise((resolve, reject) => {
if ( ! this.connected )
@ -503,22 +519,28 @@ export default class SocketClient extends Module {
subscribe(referrer, ...topics) {
const t = this._topics;
let changed = false;
for(const topic of topics) {
if ( ! t.has(topic) ) {
if ( this.connected )
this._send('sub', topic);
t.set(topic, new Set);
changed = true;
}
const tp = t.get(topic);
tp.add(referrer);
}
if ( changed )
this.emit(':sub-change');
}
unsubscribe(referrer, ...topics) {
const t = this._topics;
let changed = false;
for(const topic of topics) {
if ( ! t.has(topic) )
continue;
@ -527,11 +549,15 @@ export default class SocketClient extends Module {
tp.delete(referrer);
if ( ! tp.size ) {
changed = true;
t.delete(topic);
if ( this.connected )
this._send('unsub', topic);
}
}
if ( changed )
this.emit(':sub-change');
}