diff options
| author | oldmud0 <oldmud0@users.noreply.github.com> | 2019-07-01 21:48:00 -0500 |
|---|---|---|
| committer | oldmud0 <oldmud0@users.noreply.github.com> | 2019-07-01 21:48:00 -0500 |
| commit | 393142f7001269140897a8ca191884e8c29bb699 (patch) | |
| tree | 04630080d143a2432f1aa9df9c7689bc078e5354 /webAO/master.js | |
| parent | 3120cca6945ee8fa1dda40370fc9ee74265dc982 (diff) | |
(See commit message)
This commit includes another pass of refactoring to webAO, but
could not be tested because it has become virtually impossible
to compile GoldenLayout correctly and have it be detected as a
module by webpack. GoldenLayout has also been dormant for an
alarming amount of time, and its new maintainers have not been
doing a stellar job releasing bug fixes.
So, I give up trying to build webAO.
It's a heaping mess written in vanilla HTML/CSS/JS without the
use of a proper web framework, dependent on a raw TCP protocol
designed 7 years ago, only to be wrapped with yet another
protocol that only half the servers *want* to support, because
webAO is so bad that only incompetent players would want to keep
using it. (Unless you are a Chromebook player, in which case I am
sorry for hurling insults at you.)
webAO started off as an experiment by sD, but became real only
because I made it real. I was the one who added support for
it for tsuserver; I was the one who made the UI vaguely acceptable;
I was the one who added a button for it on the home page. It's
really my fault that this abomination lives on. I should have
learned a legitimate web framework and rewritten it when I
had the chance.
Diffstat (limited to 'webAO/master.js')
| -rw-r--r-- | webAO/master.js | 115 |
1 files changed, 43 insertions, 72 deletions
diff --git a/webAO/master.js b/webAO/master.js index 4c29a7c..0b2bcf9 100644 --- a/webAO/master.js +++ b/webAO/master.js @@ -1,67 +1,45 @@ -MASTERSERVER_IP = "master.aceattorneyonline.com:27014" -//MASTERSERVER_IP = "192.168.1.28:27014" +const MASTERSERVER_IP = "master.aceattorneyonline.com:27014"; -masterserver = new WebSocket("ws://" + MASTERSERVER_IP); +const masterserver = new WebSocket("ws://" + MASTERSERVER_IP); masterserver.onopen = (evt) => onOpen(evt); -masterserver.onclose = (evt) => onClose(evt); masterserver.onmessage = (evt) => onMessage(evt); -masterserver.onerror = (evt) => onError(evt); -var idnow; -var descs = []; -descs[99]="This is your computer on port 27016"; -var onlinec = []; -var serverpics = []; -function UrlExists(url) -{ - var http = new XMLHttpRequest(); - http.open('HEAD', url, false); - http.send(); - return http.status != 404; -} +const descs = []; +descs[99] = "This is your computer on port 27016"; +const onlinec = []; function setServ(ID) { console.log(descs[ID]); - if (descs[ID] != undefined) { + if (descs[ID] !== undefined) { document.getElementById("serverdescC").innerHTML = "<b>Online: "+onlinec[ID]+"</b><br>" +descs[ID]; } else { document.getElementById("serverdescC").innerHTML = ""; } -// idnow = ID; -// document.getElementById("serverthumbC").src = serverpics[ID]; -// if (UrlExists(serverpics[ID])) { -// document.getElementById("serverthumbC").src = serverpics[ID]; -// } -// else { -// document.getElementById("serverthumbC").src = "/images/static.gif"; -// } } -function onOpen(e) { - console.log("Open"); +function onOpen(_e) { masterserver.send("ID#webAO#webAO#%"); masterserver.send("ALL#%"); masterserver.send("VC#%"); -}; +} function checkOnline(serverID,coIP) { - function onCOOpen(e) { - console.log("Open"); - document.getElementById('server'+serverID).className = "available"; + function onCOOpen(_e) { + document.getElementById(`server${serverID}`).className = "available"; oserv.send("HI#webAO#%"); oserv.send("ID#webAO#webAO#%"); - }; + } + function onCOMessage(e) { - comsg = e.data; - console.log(comsg) - coheader = comsg.split('#', 2)[0]; - coarguments = comsg.split('#').slice(1) - if (coheader == 'PN') { - onlinec[serverID]=coarguments[0]+"/"+coarguments[1]; + const comsg = e.data; + const coheader = comsg.split("#", 2)[0]; + const coarguments = comsg.split("#").slice(1); + if (coheader === "PN") { + onlinec[serverID] = `${coarguments[0]}/${coarguments[1]}`; oserv.close(); } - }; + } var oserv = new WebSocket("ws://" + coIP); @@ -76,38 +54,31 @@ function checkOnline(serverID,coIP) { } function onMessage(e) { - msg = e.data; - console.log(msg) - header = msg.split('#', 2)[0]; - if (header == 'ALL') { - let servers = msg.split('#').slice(1) + const msg = e.data; + console.log(msg); + const header = msg.split("#", 2)[0]; + + if (header === "ALL") { + const servers = msg.split("#").slice(1); for (let i = 0; i < servers.length; i++) { - let serverEntry = servers[i]; - let arguments = serverEntry.split('&'); - document.getElementById('masterlist').innerHTML += - `<li id="server${i}" class="unavailable" onmouseover="setServ(${i})"><p>${arguments[0]}</p>` - + `<a class="button" href="client.html?mode=watch&ip=${arguments[2]}:${arguments[3]}">Watch</a>` - + `<a class="button" href="client.html?mode=join&ip=${arguments[2]}:${arguments[3]}">Join</a></li><br/>`; - descs[i] = arguments[1]; - setTimeout(checkOnline(i, arguments[2] + ':' + arguments[3]), 3); + const serverEntry = servers[i]; + const args = serverEntry.split("&"); + const asset = args[4] ? `&asset=${args[4]}` : ""; + + document.getElementById("masterlist").innerHTML += + `<li id="server${i}" class="unavailable" onmouseover="setServ(${i})"><p>${args[0]}</p>` + + `<a class="button" href="client.html?mode=watch&ip=${args[2]}:${args[3]}${asset}">Watch</a>` + + `<a class="button" href="client.html?mode=join&ip=${args[2]}:${args[3]}${asset}">Join</a></li><br/>`; + descs[i] = args[1]; + setTimeout(checkOnline(i, args[2] + ":" + args[3]), 3000); } + } else if (header === "servercheok") { + const args = msg.split("#").slice(1); + console.log(args); + document.getElementById("clientinfo").innerHTML = `Client version: ${args[0]}`; + } else if (header === "SV") { + const args = msg.split("#").slice(1); + console.log(args); + document.getElementById("serverinfo").innerHTML = `Master server version: ${args[0]}`; } - else if (header == 'servercheok') { - let arguments = msg.split('#').slice(1) - console.log(arguments); - document.getElementById('clientinfo').innerHTML = "Client version: " + arguments[0]; - } - else if (header == 'SV') { - let arguments = msg.split('#').slice(1) - console.log(arguments); - document.getElementById('serverinfo').innerHTML = "Master server version: "+arguments[0]; - } -}; - -function onError(e) { - //Stub -}; - -function onClose(e) { - //Stub -}; +} |
