From 6f162dcf90a6aa671eb351dc25cb01e2d9cbd3cb Mon Sep 17 00:00:00 2001 From: TrueKuehli Date: Mon, 1 Oct 2018 18:10:37 +0200 Subject: A lot of changes I shoud have written a better commit, I know! --- WebInterface/NodeJSServer/src/modules/server-client.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'WebInterface/NodeJSServer/src/modules/server-client.js') diff --git a/WebInterface/NodeJSServer/src/modules/server-client.js b/WebInterface/NodeJSServer/src/modules/server-client.js index ea37e1e..1bc9822 100644 --- a/WebInterface/NodeJSServer/src/modules/server-client.js +++ b/WebInterface/NodeJSServer/src/modules/server-client.js @@ -10,9 +10,12 @@ export default class ServerClient { * @param {string} url URL of server running signalR * @param {string} serverListingId HTML ID of server-listing element, * to populate with available games + * @param {BannerController} notifications Notification Manager + * @param {array} ui UI Elements to reload on login * @param {boolean} [debug=false] Enable debug output? */ - constructor(url, serverListingId, debug = false) { + constructor(url, serverListingId, notifications, ui, debug = false) { + this.ui = ui; const connectionBuilder = new signalR.HubConnectionBuilder() .withUrl(url); @@ -30,7 +33,7 @@ export default class ServerClient { // Initialize refreshing (blocks new refreshes if true) this.refreshing = false; - this.serverListing = new ServerListing(serverListingId); + this.serverListing = new ServerListing(serverListingId, notifications); this.messageHandling(); } @@ -44,7 +47,7 @@ export default class ServerClient { this.connection.on('ListGroups', (groups) => { // Populate server listing this.serverListing.flushElements(); - this.serverListing.addElements(groups); + this.serverListing.addElements(groups, this, this.ui); this.connection.off('ListGroups'); this.refreshing = false; @@ -76,7 +79,7 @@ export default class ServerClient { */ sendLogin(group, password, username, callback) { this.connection.on('LoginResponse', (result) => { - callback(result); + callback(result, this); this.connection.off('LoginResponse'); }); this.connection.invoke('Login', group, username, password); @@ -99,6 +102,7 @@ export default class ServerClient { /** * Callback to call with response to login request * @callback ServerClient~loginCallback - * @param {number} result 0: Success, 1: PasswordError, 2:UsernameTaken - * , 3:Unknown Error + * @param {number} result 0: Success, 1: PasswordError, 2:UsernameTaken, + * 3:Unknown Error + * @param {ServerClient} client ServerClient object, that handled the login */ -- cgit v1.2.3-70-g09d2