-
Notifications
You must be signed in to change notification settings - Fork 182
Adding a new Command
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)
-
Add the function to the Core api
At the bottom of
interfaces/uproxy_core_api.ts
, there is aCoreAPI
interface, the function you want to create should be added to this. -
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 aPromise
orvoid
. -
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 ininterfaces/uproxy_core_api.ts
that represents this new command. -
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 returningthis.promiseCommand(ENUM_VALUE, argument_to_your_function)
if you are returning a promise or callingthis.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.