diff options
author | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:53:30 +0200 |
---|---|---|
committer | Dennis Kobert <d-kobert@web.de> | 2019-06-11 23:53:30 +0200 |
commit | 3a3d0fc3d4733f8908e23a03f860d76340479ec4 (patch) | |
tree | cf4b82f61d01d2a24836e9820d73972436847982 /WebInterface/NodeJSServer/src/js/modules/networking/commands | |
parent | c28c9fafa2c74b101f7ce777aac722dcdeecefc6 (diff) |
Reorganize Project structure
Diffstat (limited to 'WebInterface/NodeJSServer/src/js/modules/networking/commands')
6 files changed, 0 insertions, 215 deletions
diff --git a/WebInterface/NodeJSServer/src/js/modules/networking/commands/_command.js b/WebInterface/NodeJSServer/src/js/modules/networking/commands/_command.js deleted file mode 100644 index 46a1a14..0000000 --- a/WebInterface/NodeJSServer/src/js/modules/networking/commands/_command.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Parent Command class which all commands inherit from - */ -export default class Command { - /** - * Constructs basic command object - * @param {Interface} iface Interface to communicate over - */ - constructor(iface) { - this.iface = iface; - } - - /** - * Registers public command names to interface - * @param {String} name Name to register under - * @param {...String} commandNames Names of public commands - */ - registerPublic(name, ...commandNames) { - this.iface.addObject(this, name, ['destroy'].concat(commandNames)); - } - - /** - * Removes from iface - */ - destroy() { - this.iface.removeObject(this); - } -} diff --git a/WebInterface/NodeJSServer/src/js/modules/networking/commands/login/createServer.js b/WebInterface/NodeJSServer/src/js/modules/networking/commands/login/createServer.js deleted file mode 100644 index 78b2a1b..0000000 --- a/WebInterface/NodeJSServer/src/js/modules/networking/commands/login/createServer.js +++ /dev/null @@ -1,23 +0,0 @@ -import Command from '../_command'; - -/** - * Handles creation of Servers - */ -export default class CreateServer extends Command { - /** - * Registers interface for communication with other objects - * @param {Interface} iface - */ - constructor(iface) { - super(iface); - this.registerPublic('createServer', 'createServer'); - this.refreshing = false; - } - - /** - * TODO: - */ - createServer() { - - } -} diff --git a/WebInterface/NodeJSServer/src/js/modules/networking/commands/login/listServers.js b/WebInterface/NodeJSServer/src/js/modules/networking/commands/login/listServers.js deleted file mode 100644 index 2c2bc11..0000000 --- a/WebInterface/NodeJSServer/src/js/modules/networking/commands/login/listServers.js +++ /dev/null @@ -1,43 +0,0 @@ -import Command from '../_command'; - -/** - * Handles serverList commands - */ -export default class ListServers extends Command { - /** - * Registers interface for communication with other objects - * @param {Interface} iface - */ - constructor(iface) { - super(iface); - this.registerPublic('listServers', 'listServers'); - this.refreshing = false; - } - - /** - * Requests server list from the server - */ - listServers() { - if (this.refreshing) return; // If already refreshing, no new request - - let listFn = (groups) => { - // Populate server listing - this.iface.callMethod('serverListing', 'flushElements'); - this.iface.callMethod('serverListing', 'addElements', groups, this.iface); - // Unbind network function - this.iface.callMethod('networker', 'removeHandler', 'ListGroups'); - this.refreshing = false; - }; - let errorHandler = (err) => { - this.refreshing = false; - console.error(err.toString()); - }; - - this.iface.callMethod('networker', 'registerHandler', - 'ListGroups', listFn); - this.iface.callMethod('networker', 'sendRequest', - 'GetGroups', errorHandler); - - this.refreshing = true; - } -} diff --git a/WebInterface/NodeJSServer/src/js/modules/networking/commands/login/login.js b/WebInterface/NodeJSServer/src/js/modules/networking/commands/login/login.js deleted file mode 100644 index 44a6c94..0000000 --- a/WebInterface/NodeJSServer/src/js/modules/networking/commands/login/login.js +++ /dev/null @@ -1,54 +0,0 @@ -import Command from '../_command'; -import LoginModal from '../../../ui/components/modal/login-modal'; - -/** - * Handles login to server - */ -export default class Login extends Command { - /** - * Registers interface for communication with other objects - * @param {Interface} iface - */ - constructor(iface) { - super(iface); - this.registerPublic('login', 'sendLogin', 'showLogin'); - this.refreshing = false; - } - - /** - * Shows a login modal - * @param {String} name - */ - showLogin(name) { - new LoginModal(this.iface, name); - } - - /** - * Registers login response method - */ - registerLoginResponse() { - this.iface.callMethod('networker', 'registerHandler', 'LoginResponse', - (result) => { - if (result == 0) { - this.iface.callMethod('modal', 'close'); - this.iface.callMethod('router', 'routePlay'); - this.iface.callMethod('networker', 'removeHandler', - 'LoginResponse'); - } else { - this.iface.callMethod('modal', 'loginFailed', result); - } - }); - } - - /** - * Sends a login request - * @param {string} group Group name to join - * @param {string} password Password to send as SHA-256 Base64 String - * @param {string} username Display name to use - */ - sendLogin(group, password, username) { - this.registerLoginResponse(); - this.iface.callMethod('networker', 'sendRequest', 'Login', - (err) => console.error(err), group, username, password); - } -} diff --git a/WebInterface/NodeJSServer/src/js/modules/networking/commands/loginCmds.js b/WebInterface/NodeJSServer/src/js/modules/networking/commands/loginCmds.js deleted file mode 100644 index bc5d8a7..0000000 --- a/WebInterface/NodeJSServer/src/js/modules/networking/commands/loginCmds.js +++ /dev/null @@ -1,36 +0,0 @@ -import ListServers from './login/listServers'; -import CreateServer from './login/createServer'; -import Login from './login/login'; - -/** - * Manages commands related to the login page - */ -export default class LoginCommands { - /** - * Initializes the login commands - * @param {Interface} iface Interface for inter-object communication - */ - constructor(iface) { - this.iface = iface; - this.cmds = []; - this.registerCommands(); - } - - /** - * Registers all the available commands - */ - registerCommands() { - this.cmds.push(new ListServers(this.iface)); - this.cmds.push(new CreateServer(this.iface)); - this.cmds.push(new Login(this.iface)); - } - - /** - * Destroys all attached commands - */ - destroy() { - for (let cmd of this.cmds) { - cmd.destroy(); - } - } -} diff --git a/WebInterface/NodeJSServer/src/js/modules/networking/commands/playCmds.js b/WebInterface/NodeJSServer/src/js/modules/networking/commands/playCmds.js deleted file mode 100644 index 94cd6ba..0000000 --- a/WebInterface/NodeJSServer/src/js/modules/networking/commands/playCmds.js +++ /dev/null @@ -1,31 +0,0 @@ -// import ListServers from './login/listServers'; - -/** - * Manages commands related to the login page - */ -export default class LoginCommands { - /** - * Initializes the login commands - * @param {Interface} iface Interface for inter-object communication - */ - constructor(iface) { - this.iface = iface; - this.cmds = []; - } - - /** - * Registers all the available commands - */ - registerCommands() { - // this.cmds.push(new ListServers(iface)); - } - - /** - * Destroys all attached commands - */ - destroy() { - for (let cmd of this.cmds) { - cmd.destroy(); - } - } -} |