diff options
author | TrueKuehli <rctcoaster2000@hotmail.de> | 2018-11-27 12:16:33 +0100 |
---|---|---|
committer | TrueKuehli <rctcoaster2000@hotmail.de> | 2018-11-27 12:16:33 +0100 |
commit | 9f0b255f32dfa81bffe75f89335a78a659b4ce6a (patch) | |
tree | c4345ef6f98fee35f326bc06c29cada542a78e43 /WebInterface/NodeJSServer/src/modules/playModule.js | |
parent | a653a4efc60ef0bbc18e65cb11a4bd8c06c7ad5c (diff) |
Reworked the code, but currently unable to test, so bugs are bound to be in there
Will test it sometime later. There also might still be stuff, that has yet to be reworked.
Diffstat (limited to 'WebInterface/NodeJSServer/src/modules/playModule.js')
-rw-r--r-- | WebInterface/NodeJSServer/src/modules/playModule.js | 46 |
1 files changed, 0 insertions, 46 deletions
diff --git a/WebInterface/NodeJSServer/src/modules/playModule.js b/WebInterface/NodeJSServer/src/modules/playModule.js deleted file mode 100644 index 931f598..0000000 --- a/WebInterface/NodeJSServer/src/modules/playModule.js +++ /dev/null @@ -1,46 +0,0 @@ -// TODO: Handle disconnect - -/** - * Handles ingame networking; - */ -export default class GameClient { - /** - * Defines basic attributes - * @param {string} user The username of the player - * @param {HubConnection} connection Already established connection to the - * server - */ - constructor(user, connection) { - this.user = user; - this.connection = connection; - } - - /** - * Registers chat html component - * @param {string} chatId Id of chat component - */ - registerChat(chatId) { - this.chat = document.getElementById(chatId); - this.messageList = this.chat.querySelector('#message-list'); - this.messageInput = this.chat.querySelector('#input-message'); - this.messageSend = this.chat.querySelector('#send-message'); - - this.connection.on('ReceiveMessage', (user, message) => { - let msg = message.replace(/&/g, '&') - .replace(/</g, '<') - .replace(/>/g, '>'); - let encodedMsg = user + ' sagt: ' + msg; - - let messageP = document.createElement('p'); - messageP.class = 'message'; - messageP.textContent = encodedMsg; - - this.messageList.appendChild(messageP); - }); - - this.messageSend.addEventListener('click', () => { - let message = this.messageInput.value; - this.connection.invoke('SendMessage', this.user, message); - }); - } -} |