[HQ] Toggle chat on connect

This commit is contained in:
vilP1L
2019-06-07 21:50:06 -04:00
parent c838e356d4
commit 113f67babe

View File

@@ -39,6 +39,7 @@ export default class Client {
this.letter = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'[index % 26];
this.correctGuess = false;
this.puzzleState = [];
this.chatVisible = true;
}
async login() {
@@ -93,6 +94,7 @@ export default class Client {
if (this.debug) console.log(`${` Client ${this.index} [DEBUG] `.bgBlue.black}${' PING '.bgGreen.black}`);
return true;
}, 5000);
this.toggleChat();
this.subscribe();
};
this.ws.onclose = () => {
@@ -117,6 +119,15 @@ export default class Client {
return true;
}
toggleChat() {
if (!this.ws || this.ws.readyState !== this.ws.OPEN) return console.log('No WebSocket connection is active.');
this.ws.send(JSON.stringify({
type: 'chatVisibilityToggled',
chatVisible: !this.chatVisible,
}));
return true;
}
parse(msg) {
const data = JSON.parse(msg);
switch (data.type) {