diff --git a/src/mami.js/main.js b/src/mami.js/main.js index 5457ca2..d383510 100644 --- a/src/mami.js/main.js +++ b/src/mami.js/main.js @@ -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; diff --git a/src/mami.js/sockchat_old.js b/src/mami.js/sockchat_old.js index 092a3bb..15982cb 100644 --- a/src/mami.js/sockchat_old.js +++ b/src/mami.js/sockchat_old.js @@ -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 => {