summaryrefslogtreecommitdiff
path: root/WebInterface/src/js/modules/networking/commands/_command.js
blob: 46a1a14754183e22b2dd1c90126990c00094a7ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
 * 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);
  }
}