Removed common reference from Sock Chat implementation.

This commit is contained in:
flash 2024-03-01 19:17:20 +00:00
parent f50785a209
commit 9f61c0d4b9
2 changed files with 6 additions and 4 deletions

View file

@ -584,7 +584,7 @@ window.Umi = { UI: {}, Protocol: { SockChat: { Protocol: {} } } };
'joinfail': 'You are banned.',
};
const sockChat = new Umi.Protocol.SockChat.Protocol;
const sockChat = new Umi.Protocol.SockChat.Protocol(futami.get('ping') * 1000);
MamiCompat('Umi.Server', { get: () => sockChat, configurable: true });
let dumpEvents = false;

View file

@ -1,9 +1,11 @@
#include common.js
#include eventtarget.js
#include servers.js
#include websock.js
Umi.Protocol.SockChat.Protocol = function() {
Umi.Protocol.SockChat.Protocol = function(pingDuration) {
if(typeof pingDuration !== 'number')
throw 'pingDuration must be a number';
const eventTarget = new MamiEventTarget('mami:proto');
const parseUserColour = str => {
@ -93,7 +95,7 @@ Umi.Protocol.SockChat.Protocol = function() {
send('2', selfUserId, text);
};
const startKeepAlive = () => sock?.sendInterval(`0\t${selfUserId}`, futami.get('ping') * 1000);
const startKeepAlive = () => sock?.sendInterval(`0\t${selfUserId}`, pingDuration);
const stopKeepAlive = () => sock?.clearIntervals();
const onOpen = ev => {