Skip to content

Adding a new Command

Jonathan Pevarnek edited this page Jul 12, 2016 · 1 revision

It may sometimes be necessary to add new commands to uProxy. These commands are used by the user-interface ("front-end") components of the program to either send information to or get information from the core ("back-end"). Essentially, they are a way for something in generic_ui/scripts/ui.ts to call code in generic_core/uproxy_core.ts. Below is a short guide of what you need to do in order to add a new command

(note: reference commits will be added later)

  1. Add the function to the Core api

    At the bottom of interfaces/uproxy_core_api.ts, there is a CoreAPI interface, the function you want to create should be added to this.

  2. Add the code to call

    For this step, make a function within generic_core/uproxy_core.ts that contains the code you want to be executed. The return value of the function should be either a Promise or void.

  3. Add a command number

    For any command to be called from the front-end, it needs a number that can be sent over the wire. Add a new value to the Commands enum in interfaces/uproxy_core_api.ts that represents this new command.

  4. Add a function to the core connector in the UI

    Add a function to generic_ui/scripts/core_connector.ts. It should be a single line and either returning this.promiseCommand(ENUM_VALUE, argument_to_your_function) if you are returning a promise or calling this.sendCommand(ENUM_VALUE, argument_to_your_function) if there is no return value.

That's it, you've added your function! It can immediately be used anywhere in the front-end and you can assume that the Core has it.

Clone this wiki locally