mami/src/proto.js/sockchat/ctx.js
flash cf71bab92d Rewrote connection handling.
This has been in the works for over a month and might break things because it's a very radical change.
If it causes you to be unable to join chat, report it on the forum or try joining using the legacy chat on https://sockchat.flashii.net.
2024-04-17 15:42:50 +00:00

44 lines
996 B
JavaScript

#include sockchat/keepalive.js
const SockChatContext = function(dispatch, sendPing, pingDelay) {
if(typeof dispatch !== 'function')
throw 'dispatch must be a function';
let userId;
const public = {
get userId() { return userId; },
set userId(value) { userId = value; },
get isAuthed() { return userId !== undefined; },
channelName: undefined,
pseudoChannelName: undefined,
wasConnected: false,
wasKicked: false,
isRestarting: false,
lastPing: undefined,
openPromise: undefined,
authPromise: undefined,
pingPromise: undefined,
dispatch: dispatch,
};
public.keepAlive = new SockChatKeepAlive(public, sendPing, pingDelay);
// what is this? C#?
public.dispose = () => {
public.keepAlive?.stop();
public.openPromise?.cancel();
public.authPromise?.cancel();
public.pingPromise?.cancel();
};
return public;
};