From bb56dfca8eecb928f7f6e72104437cb143fdffc8 Mon Sep 17 00:00:00 2001 From: tailuge Date: Sat, 4 Jan 2025 15:06:29 +0000 Subject: [PATCH] tidy --- README.md | 6 ++- dist/2p.html | 4 +- dist/lobby/lobby.css | 32 --------------- dist/lobby/lobby.html | 52 ------------------------ dist/lobby/lobby.js | 94 ------------------------------------------- dist/multi.html | 17 +------- dist/server.js | 1 - 7 files changed, 7 insertions(+), 199 deletions(-) delete mode 100644 dist/lobby/lobby.css delete mode 100644 dist/lobby/lobby.html delete mode 100644 dist/lobby/lobby.js delete mode 100644 dist/server.js diff --git a/README.md b/README.md index 6e1f13e8..e90e011e 100644 --- a/README.md +++ b/README.md @@ -224,9 +224,11 @@ yarn prettify ### Two player -tbd uses nchan +```shell +yarn serve +``` -open to see options +then open to see options, message server is public nchan. ## Controls diff --git a/dist/2p.html b/dist/2p.html index 2a23c022..af5c45ae 100644 --- a/dist/2p.html +++ b/dist/2p.html @@ -36,8 +36,8 @@ - - diff --git a/dist/lobby/lobby.js b/dist/lobby/lobby.js deleted file mode 100644 index e9a602dd..00000000 --- a/dist/lobby/lobby.js +++ /dev/null @@ -1,94 +0,0 @@ -const server = window.location.origin -const player1 = document.getElementById("player1") -const player2 = document.getElementById("player2") -const table = document.getElementById("table") -const ruletype = document.getElementById("ruletype") -const detail = document.getElementById("detail") -const info1 = document.getElementById("info1") -const info2 = document.getElementById("info2") -const spinner = document.getElementById("spinner") - -const renderwss = "wss://billiards.onrender.com/ws" -const github = "https://tailuge.github.io/billiards/dist/" - -let statusPage = "https://billiards.onrender.com" -let wss = renderwss -let assets = github -let link1 = "" -let link2 = "" -table.value = "Table-" + Math.floor(Math.random() * 0xffffff).toString(16) -if (location.search.includes("?mode=local")) { - wss = server.replace(/^http/, "ws") + "/ws" - assets = location.origin + "/dist/" - statusPage = "../" -} - -checkStatus({ mode: "no-cors" }) - -function checkStatus(options) { - fetch(statusPage, options) - .then((response) => { - const message = response.statusText ? response.statusText : "OK" - spinner.innerText = `${message} (${statusPage})` - }) - .catch((error) => { - spinner.innerText = error - }) - .finally(() => { - spinner.classList.remove("spinner") - }) -} - -function share() { - const shareData = { - title: "Billiards", - text: `${player1.value} is inviting you to play billiards`, - url: link2, - } - if (navigator.canShare) { - navigator - .share(shareData) - .then(() => (info2.innerText = "shared successfully")) - .catch((e) => { - console.log("Error: " + e) - info2.innerText = `${e}` - }) - } else { - info2.innerText = `link copied to clipboard` - navigator.clipboard.writeText(link2) - } -} - -function join() { - window.open(link1, "_blank").focus() -} - -function createTable() { - detail.style.visibility = "visible" - - const guid = shortGuid() - const guid1 = "p1" + guid - const guid2 = "p2" + guid - const params1 = new URLSearchParams({ - websocketserver: wss, - tableId: table.value, - name: player1.value, - clientId: guid1, - ruletype: ruletype.value, - }) - const params2 = new URLSearchParams({ - websocketserver: wss, - tableId: table.value, - name: player2.value, - clientId: guid2, - ruletype: ruletype.value, - }) - link1 = `${assets}?${params1.toString()}` - link2 = `${assets}?${params2.toString()}` - info1.innerText = link1 - info2.innerText = link2 -} - -function shortGuid() { - return Math.floor(Math.random() * 0xffffff).toString(16) -} diff --git a/dist/multi.html b/dist/multi.html index 134c177d..cdddb369 100644 --- a/dist/multi.html +++ b/dist/multi.html @@ -1,7 +1,7 @@ - multi player billiards hosting + multi player billiards testing setup @@ -53,21 +53,6 @@

tailuge/billiards multiplayer test page

>two players snooker in single window -
  • local lobby
  • - - github assets and local websocket server: - - github assets and render websocket server: - diff --git a/dist/server.js b/dist/server.js deleted file mode 100644 index 3a0452ff..00000000 --- a/dist/server.js +++ /dev/null @@ -1 +0,0 @@ -(()=>{"use strict";var t={861:function(t,e,n){var o,r=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.AbortEvent=void 0;var i=n(377),c=n(551),s=function(t){function e(){var e=t.call(this)||this;return e.type=c.EventType.ABORT,e}return r(e,t),e.prototype.applyToController=function(t){return t.handleAbort(this)},e}(i.GameEvent);e.AbortEvent=s},532:function(t,e,n){var o,r=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.AimEvent=void 0;var i=n(377),c=n(551),s=n(450),a=n(912),u=function(t){function e(){var e=t.call(this)||this;return e.offset=new a.Vector3(0,0,0),e.angle=0,e.power=0,e.pos=new a.Vector3(0,0,0),e.i=0,e.type=c.EventType.AIM,e}return r(e,t),e.prototype.applyToController=function(t){return t.handleAim(this)},e.fromJson=function(t){var n=new e;return n.pos=(0,s.vec)(t.pos),n.angle=t.angle,n.offset=(0,s.vec)(t.offset),n.power=t.power,t.i&&(n.i=t.i),n},e.prototype.copy=function(){return e.fromJson(this)},e}(i.GameEvent);e.AimEvent=u},28:function(t,e,n){var o,r=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.BeginEvent=void 0;var i=n(377),c=n(551),s=function(t){function e(){var e=t.call(this)||this;return e.type=c.EventType.BEGIN,e}return r(e,t),e.prototype.applyToController=function(t){return t.handleBegin(this)},e}(i.GameEvent);e.BeginEvent=s},202:function(t,e,n){var o,r=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.BreakEvent=void 0;var i=n(377),c=n(551),s=function(t){function e(e,n){var o=t.call(this)||this;return o.init=e,o.shots=n,o.type=c.EventType.BREAK,o}return r(e,t),e.prototype.applyToController=function(t){return t.handleBreak(this)},e.fromJson=function(t){return new e(t.init,t.shots)},e}(i.GameEvent);e.BreakEvent=s},389:function(t,e,n){var o,r=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.ChatEvent=void 0;var i=n(377),c=n(551),s=function(t){function e(e,n){var o=t.call(this)||this;return o.sender=e,o.message=n,o.type=c.EventType.CHAT,o}return r(e,t),e.prototype.applyToController=function(t){return t.handleChat(this)},e.fromJson=function(t){return new e(t.sender,t.message)},e}(i.GameEvent);e.ChatEvent=s},87:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EventHistory=void 0;var n=function(){function t(){this.sent=[]}return t.prototype.last=function(t){return t[t.length-1]},t.prototype.lastSent=function(){return this.last(this.sent)},t.prototype.lastRecv=function(){return this.recv},t.prototype.from=function(t,e){var n=t.findIndex((function(t){return t.sequence===e}));return t.slice(n)},t.prototype.nextId=function(t,e){var n=t.findIndex((function(t){return t.sequence===e}));return n{var n;Object.defineProperty(e,"__esModule",{value:!0}),e.EventType=void 0,function(t){t.BEGIN="BEGIN",t.BREAK="BREAK",t.WATCHAIM="WATCHAIM",t.AIM="AIM",t.HIT="HIT",t.STATIONARY="STATIONARY",t.CHAT="CHAT",t.ABORT="ABORT",t.PLACEBALL="PLACEBALL",t.REJOIN="REJOIN",t.RERACK="RERACK",t.STARTAIM="STARTAIM"}(n||(e.EventType=n={}))},867:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.EventUtil=void 0;var o=n(551),r=n(532),i=n(770),c=n(408),s=n(861),a=n(202),u=n(28),l=n(389),p=n(444),f=n(421),v=n(825),y=n(692),h=function(){function t(){}return t.serialise=function(t){return JSON.stringify(t)},t.fromJson=function(t){switch(t.type){case o.EventType.BEGIN:return new u.BeginEvent;case o.EventType.AIM:return r.AimEvent.fromJson(t);case o.EventType.BREAK:return a.BreakEvent.fromJson(t);case o.EventType.WATCHAIM:return i.WatchEvent.fromJson(t.json);case o.EventType.HIT:return c.HitEvent.fromJson(t);case o.EventType.CHAT:return l.ChatEvent.fromJson(t);case o.EventType.REJOIN:return p.RejoinEvent.fromJson(t);case o.EventType.ABORT:return new s.AbortEvent;case o.EventType.PLACEBALL:return f.PlaceBallEvent.fromJson(t);case o.EventType.RERACK:return v.RerackEvent.fromJson(t);case o.EventType.STARTAIM:return y.StartAimEvent.fromJson(t);default:throw Error("Unknown GameEvent :"+t)}},t.fromSerialised=function(e){var n=JSON.parse(e),o=t.fromJson(n);return"sequence"in n&&(o.sequence=n.sequence),"clientId"in n&&(o.clientId=n.clientId),o},t}();e.EventUtil=h},377:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.GameEvent=void 0;var n=function(){};e.GameEvent=n},408:function(t,e,n){var o,r=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.HitEvent=void 0;var i=n(377),c=n(551),s=function(t){function e(e){var n=t.call(this)||this;return n.type=c.EventType.HIT,n.tablejson=e,n}return r(e,t),e.prototype.applyToController=function(t){return t.handleHit(this)},e.fromJson=function(t){return new e(t.tablejson)},e}(i.GameEvent);e.HitEvent=s},421:function(t,e,n){var o,r=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.PlaceBallEvent=void 0;var i=n(377),c=n(551),s=n(450),a=function(t){function e(e,n){var o=t.call(this)||this;return o.pos=e,o.allTable=n,o.type=c.EventType.PLACEBALL,o}return r(e,t),e.fromJson=function(t){return new e((0,s.vec)(t.pos),t.allTable)},e.prototype.applyToController=function(t){return t.handlePlaceBall(this)},e}(i.GameEvent);e.PlaceBallEvent=a},444:function(t,e,n){var o,r=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.RejoinEvent=void 0;var i=n(377),c=n(551),s=function(t){function e(e,n){void 0===e&&(e=""),void 0===n&&(n="");var o=t.call(this)||this;return o.type=c.EventType.REJOIN,o.clientResendFrom=e,o.serverResendFrom=n,o}return r(e,t),e.prototype.applyToController=function(t){return t.handleRejoin(this)},e.fromJson=function(t){return new e(t.clientResendFrom,t.serverResendFrom)},e}(i.GameEvent);e.RejoinEvent=s},825:function(t,e,n){var o,r=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.RerackEvent=void 0;var i=n(377),c=n(551),s=function(t){function e(){var e=t.call(this)||this;return e.type=c.EventType.RERACK,e}return r(e,t),e.prototype.applyToController=function(t){return t.container.table.updateFromSerialised(this.ballinfo),t},e.fromJson=function(t){var n=new e;return n.ballinfo=t,n},e}(i.GameEvent);e.RerackEvent=s},692:function(t,e,n){var o,r=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.StartAimEvent=void 0;var i=n(377),c=n(551),s=function(t){function e(e){void 0===e&&(e=0);var n=t.call(this)||this;return n.foul=0,n.type=c.EventType.STARTAIM,n.foul=e,n}return r(e,t),e.prototype.applyToController=function(t){return t.handleStartAim(this)},e.fromJson=function(t){return new e(t.foul)},e}(i.GameEvent);e.StartAimEvent=s},770:function(t,e,n){var o,r=this&&this.__extends||(o=function(t,e){return o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},o(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0}),e.WatchEvent=void 0;var i=n(377),c=n(551),s=function(t){function e(e){var n=t.call(this)||this;return n.type=c.EventType.WATCHAIM,n.json=e,n}return r(e,t),e.prototype.applyToController=function(t){return t.handleWatch(this)},e.fromJson=function(t){return new e(t)},e}(i.GameEvent);e.WatchEvent=s},986:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Lobby=void 0;var o=n(28),r=n(389),i=n(867),c=n(133),s=n(145),a=n(489),u=function(){function t(){this.tables=new c.Tables,this.seq=1e3}return t.prototype.createClient=function(t,e,n,o){if(!e||!n){var r="Invalid: Connection request must contain tableId and clientId";return s.ServerLog.log(r),void t.send(r)}return{ws:t,name:o,clientId:n}},t.prototype.joinTable=function(t,e,n,r){void 0===n&&(n=""),void 0===r&&(r="");var i=this.tables.getTable(e);return i.isActive(t)&&""===n&&""===r?(this.sendInfo(t,e,"Already joined in another window"),!1):i.isRejoin(t)?this.rejoin(t,i,n,r):i.isFull()?(this.sendInfo(t,e,"Table already full"),!1):i.hasNoHistory(t)&&r?(this.sendInfo(t,e,"Cannot rejoin empty table"),!1):(i.join(t),1==i.clients.length?(this.sendInfo(t,e,"Waiting for opponent..."),!0):(this.notifyJoined(i),this.send(t,e,new o.BeginEvent),!0))},t.prototype.rejoin=function(t,e,n,o){var r=this,i=new a.Rejoin(t,e,n,o),c=i.delta();e.leave(t),e.rejoin(t),this.notifyOthers(t,e,"".concat(t.name," rejoined"));var u=i.replayEvents(c);return this.send(t,e.tableId,c),u.forEach((function(n){s.ServerLog.log("replay ".concat(n.sequence," ").concat(n.type)),r.send(t,e.tableId,n)})),!0},t.prototype.notifyOthers=function(t,e,n){var o=this;e.otherClients(t).forEach((function(t){o.sendInfo(t,e.tableId,n)}))},t.prototype.notifyJoined=function(t){var e=this,n="".concat(t.clients.map((function(t){return t.name})).join()," have joined ").concat(t.tableId);t.clients.forEach((function(o){e.sendInfo(o,t.tableId,n)}))},t.prototype.handleTableMessage=function(t,e,n){var o=this,r=this.tables.getTable(e),c=n.toString(),s=i.EventUtil.fromSerialised(c);r.recordRecvEvent(t,s),r.otherClients(t).forEach((function(t){o.send(t,e,s)})),r.spectators.forEach((function(t){o.send(t,e,s)}))},t.prototype.handleLeaveTable=function(t,e){s.ServerLog.log("".concat(t.name,":").concat(t.clientId," closed connection"));var n=this.tables.getTable(e);s.ServerLog.log("current clients: ".concat(n.clients.map((function(t){return t.clientId}))))},t.prototype.message=function(t,e){var n=new r.ChatEvent(t,e);return n.sequence="server-".concat(this.seq++),n},t.prototype.sendInfo=function(t,e,n){this.send(t,e,this.message("info",n))},t.prototype.send=function(t,e,n){var o,r;(null===(o=t.ws)||void 0===o?void 0:o.readyState)>=2?s.ServerLog.log("not sending to ".concat(t.name,":").concat(t.clientId)):(this.tables.getTable(e).recordSentEvent(t,n),null===(r=t.ws)||void 0===r||r.send(i.EventUtil.serialise(n)),s.ServerLog.logEvent("sending to ".concat(t.name,":").concat(t.clientId),n))},t.prototype.handleUnspectateTable=function(t,e){return s.ServerLog.log("".concat(t.name,":").concat(t.clientId," unspectating ").concat(e)),this.tables.getTable(e).spectatorLeave(t),!0},t.prototype.spectateTable=function(t,e){return s.ServerLog.log("".concat(t.name,":").concat(t.clientId," spectating ").concat(e)),this.tables.getTable(e).spectatorJoin(t),!0},t}();e.Lobby=u},489:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Rejoin=void 0;var o=n(444),r=n(145),i=function(){function t(t,e,n,o){this.client=t,this.tableInfo=e,this.clientLastSent=n,this.clientLastRecv=o,this.history=this.tableInfo.history(this.client)}return t.prototype.delta=function(){var t=new o.RejoinEvent,e=this.history.lastSent(),n=this.history.lastRecv();return r.ServerLog.log("Calculate rejoin actions for ".concat(this.client.name," \n with clientLastSent=").concat(this.clientLastSent,"\n lastRecvFromClient=").concat(null==n?void 0:n.sequence,"\n clientLastRecv=").concat(this.clientLastRecv,"\n lastSentToClient=").concat(null==e?void 0:e.sequence)),e&&(this.clientLastRecv?e.sequence!==this.clientLastRecv&&(t.serverResendFrom=this.history.nextId(this.history.sent,this.clientLastRecv)):t.serverResendFrom=this.history.sent[0].sequence),""!==this.clientLastSent&&(n?n.sequence!==this.clientLastSent&&(t.clientResendFrom=n.sequence):t.clientResendFrom="*"),t},t.prototype.replayEvents=function(t){return t.serverResendFrom?this.history.from(this.history.sent,t.serverResendFrom):[]},t}();e.Rejoin=i},145:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ServerLog=void 0;var o=n(551),r=function(){function t(){}return t.log=function(e){t.enable&&console.log(e);var n="".concat((new Date).toISOString()," ").concat(e);t.record+="".concat(n,"\n")},t.logEvent=function(e,n){n.type!==o.EventType.AIM&&(n.type!==o.EventType.CHAT&&n.type!==o.EventType.REJOIN?t.log("".concat(e," ").concat(n.type)):t.log("".concat(e," ").concat(JSON.stringify(n))))},t.record="",t.enable=!1,t}();e.ServerLog=r},862:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SocketServer=void 0;var o=n(86),r=n(986),i=n(145),c=function(){function t(t){var e=this;this.wss=new o.WebSocketServer({noServer:!0}),this.lobby=new r.Lobby,this.port=t,i.ServerLog.log("WebSocketServer running on port ".concat(t)),this.wss.on("connection",(function(t,n){e.connection(t,n)}))}return t.prototype.parse=function(t){var e=t.split("?").pop();return new URLSearchParams(e)},t.prototype.connection=function(t,e){var n,o,r,c=this,s=this.parse(e.url),a=s.get("clientId"),u=s.get("tableId"),l=null!==(n=s.get("sent"))&&void 0!==n?n:"",p=null!==(o=s.get("recv"))&&void 0!==o?o:"",f=null!==(r=s.get("name"))&&void 0!==r?r:"anonymous";i.ServerLog.log("".concat(f,":").concat(a," requesting to join ").concat(u));var v=this.lobby.createClient(t,u,a,f);if(v)return s.has("spectator")?(this.lobby.spectateTable(v,u),void t.on("close",(function(t){c.lobby.handleUnspectateTable(v,u)}))):void(this.lobby.joinTable(v,u,l,p)&&(t.on("message",(function(t){c.lobby.handleTableMessage(v,u,t)})),t.on("close",(function(t){c.lobby.handleLeaveTable(v,u)}))))},t}();e.SocketServer=c},866:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.TableInfo=void 0;var o=n(87),r=function(){function t(t){this.owningClientIds=[],this.clients=[],this.spectators=[],this.eventHistory=new Map,this.tableId=t}return t.prototype.history=function(t){return this.eventHistory.has(t.clientId)||this.eventHistory.set(t.clientId,new o.EventHistory),this.eventHistory.get(t.clientId)},t.prototype.hasNoHistory=function(t){return 0==this.history(t).sent.length&&!this.history(t).recv},t.prototype.recordSentEvent=function(t,e){this.history(t).sent.push(e)},t.prototype.recordRecvEvent=function(t,e){this.history(t).recv=e},t.prototype.join=function(t){this.owningClientIds.push(t.clientId),this.clients.push(t)},t.prototype.spectatorJoin=function(t){this.spectators.push(t)},t.prototype.spectatorLeave=function(t){this.spectators=this.spectators.filter((function(e){return e.clientId!==t.clientId}))},t.prototype.rejoin=function(t){this.clients.push(t)},t.prototype.leave=function(t){this.clients=this.otherClients(t)},t.prototype.otherClients=function(t){return this.clients.filter((function(e){return e.clientId!==t.clientId}))},t.prototype.isRejoin=function(t){return this.owningClientIds.includes(t.clientId)},t.prototype.isActive=function(t){return this.clients.some((function(e){return e.clientId===t.clientId}))},t.prototype.isFull=function(){return 2==this.clients.length},t}();e.TableInfo=r},133:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Tables=void 0;var o=n(866),r=function(){function t(){this.tables=new Map}return t.prototype.getTable=function(t){return this.tables.has(t)||this.tables.set(t,new o.TableInfo(t)),this.tables.get(t)},t}();e.Tables=r},450:(t,e,n)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.up=e.zero=void 0,e.vec=function(t){return new o.Vector3(t.x,t.y,t.z)},e.upCross=function(t){return r.copy(e.up).cross(t)},e.norm=function(t){return i.copy(t).normalize()},e.passesThroughZero=function(t,e){return c.copy(t).add(e).dot(t)<=0},e.unitAtAngle=function(t){return new o.Vector3(1,0,0).applyAxisAngle(e.up,t)},e.round=s,e.round2=a,e.roundVec=function(t){return t.x=s(t.x),t.y=s(t.y),t.z=s(t.z),t},e.roundVec2=function(t){return t.x=a(t.x),t.y=a(t.y),t.z=a(t.z),t};var o=n(912);e.zero=new o.Vector3(0,0,0),e.up=new o.Vector3(0,0,1);var r=new o.Vector3;var i=new o.Vector3;var c=new o.Vector3;function s(t){return Math.sign(t)*Math.floor(1e4*(Math.abs(t)+Number.EPSILON))/1e4}function a(t){return Math.round(100*(t+Number.EPSILON))/100}},252:t=>{t.exports=require("express")},912:t=>{t.exports=require("three")},86:t=>{t.exports=require("ws")}},e={};function n(o){var r=e[o];if(void 0!==r)return r.exports;var i=e[o]={exports:{}};return t[o].call(i.exports,i,i.exports,n),i.exports}(()=>{var t=n(252),e=n(862),o=n(145);o.ServerLog.enable=!0,o.ServerLog.log("Started execution");var r=Number(process.env.PORT||8888),i=new e.SocketServer(r),c=t();c.use((function(t,e,n){e.header("Access-Control-Allow-Origin","*"),e.header("Access-Control-Allow-Methods","GET, POST, PUT, DELETE, OPTIONS"),e.header("Access-Control-Allow-Headers","Content-Type, Authorization"),"OPTIONS"===t.method?e.sendStatus(200):n()})),c.use("/dist",t.static("dist")),c.get("/logs",(function(t,e){e.send('
    '.concat(o.ServerLog.record,"
    "))})),c.get("/",(function(t,e){e.redirect("/dist/multi.html")})),o.ServerLog.log("Starting server");var s=c.listen(r,(function(){return o.ServerLog.log("Webserver running on http://localhost:".concat(r,"/dist/multi.html"))}));s.keepAliveTimeout=6e4,s.headersTimeout=6e4,s.on("upgrade",(function(t,e,n){o.ServerLog.log("upgrade request for websocket ".concat(t.url)),i.wss.handleUpgrade(t,e,n,(function(e){i.wss.emit("connection",e,t)}))}))})()})(); \ No newline at end of file