diff options
| author | Caleb <caleb.mabry.15@cnu.edu> | 2022-08-30 16:20:08 -0400 |
|---|---|---|
| committer | Caleb <caleb.mabry.15@cnu.edu> | 2022-08-30 16:20:08 -0400 |
| commit | 3d6e61c6b0962cea539c6d780d68a7ad0b64bee1 (patch) | |
| tree | af3481664cebef9e0f1afbfe74629084c897ec40 /webAO | |
| parent | be5bd2e466951a3b525a97d595e577f3194913db (diff) | |
One more handler
Diffstat (limited to 'webAO')
| -rw-r--r-- | webAO/client.ts | 29 | ||||
| -rw-r--r-- | webAO/packets/handlers/handleRMC.ts | 24 |
2 files changed, 28 insertions, 25 deletions
diff --git a/webAO/client.ts b/webAO/client.ts index bc96703..676aa3f 100644 --- a/webAO/client.ts +++ b/webAO/client.ts @@ -15,6 +15,7 @@ import vanilla_background_arr from "./constants/backgrounds.js"; import vanilla_evidence_arr from "./constants/evidence.js"; import { handleCT } from './packets/handlers/handleCT' import { handleMC } from './packets/handlers/handleMC' +import { handleRMC } from './packets/handlers/handleRMC' import chatbox_arr from "./styles/chatbox/chatboxes.js"; import iniParse from "./iniParse"; import getCookie from "./utils/getCookie"; @@ -216,7 +217,7 @@ class Client extends EventEmitter { this.on("MS", handleMS); this.on("CT", handleCT); this.on("MC", handleMC); - this.on("RMC", this.handleRMC.bind(this)); + this.on("RMC", handleRMC); this.on("CI", this.handleCI.bind(this)); this.on("SC", this.handleSC.bind(this)); this.on("EI", this.handleEI.bind(this)); @@ -438,7 +439,7 @@ class Client extends EventEmitter { (<HTMLInputElement>( document.getElementById("client_ooclog") )).value += `wait#${(<HTMLInputElement>document.getElementById("client_replaytimer")).value - }#%\r\n`; + }#%\r\n`; } } @@ -745,29 +746,7 @@ class Client extends EventEmitter { - // TODO BUG: - // this.viewport.music is an array. Therefore you must access elements - /** - * Handles a music change to an arbitrary resource, with an offset in seconds. - * @param {Array} args packet arguments - */ - handleRMC(args: string[]) { - this.viewport.music.pause(); - const { music } = this.viewport; - // Music offset + drift from song loading - music.totime = args[1]; - music.offset = new Date().getTime() / 1000; - music.addEventListener( - "loadedmetadata", - () => { - music.currentTime += parseFloat( - music.totime + (new Date().getTime() / 1000 - music.offset) - ).toFixed(3); - music.play(); - }, - false - ); - } + /** * Handles the incoming character information, and downloads the sprite + ini for it diff --git a/webAO/packets/handlers/handleRMC.ts b/webAO/packets/handlers/handleRMC.ts new file mode 100644 index 0000000..ada1ad2 --- /dev/null +++ b/webAO/packets/handlers/handleRMC.ts @@ -0,0 +1,24 @@ +import { client } from '../../client' +// TODO BUG: +// this.viewport.music is an array. Therefore you must access elements +/** + * Handles a music change to an arbitrary resource, with an offset in seconds. + * @param {Array} args packet arguments + */ +export const handleRMC = (args: string[]) => { + client.viewport.music.pause(); + const { music } = client.viewport; + // Music offset + drift from song loading + music.totime = args[1]; + music.offset = new Date().getTime() / 1000; + music.addEventListener( + "loadedmetadata", + () => { + music.currentTime += parseFloat( + music.totime + (new Date().getTime() / 1000 - music.offset) + ).toFixed(3); + music.play(); + }, + false + ); +}
\ No newline at end of file |
