-
Notifications
You must be signed in to change notification settings - Fork 11
Interface between the frontend and backend
The frontend is written in TypeScript, HTML and CSS. The backend is (will be) written in Go.
To communicate, we will use the Go backend as a "bootstrap" for the main executable. (Note: We will do the same on windows if possible, otherwise it will work differently)
If our app is structured like this: AppleBlox.app/Contents/MacOS/main
The "main executable" (listed in the app's Info.plist file) will be the main Go executable. It will launch the Neutralino executable as a subprocess, and monitor its stdOut
to read messages, and write to the stdIn
to send messages. Here's an exemple:
(Neutralino, request written in the stdOut)
{
type: "function",
function: "Roblox.window.move",
params: [300,500],
UUID: "<randomly generated UUID>"
}
(Go, response written in the stdIn)
{
type: "response",
UUID: "<UUID of the request>"
code: 200,
message: "The Roblox window was moved to $x, $y."
}
This can go both way, the backend can also do a request.
(Go, request written in the stdIn)
{
type: "function",
function: "Neutralino.window.abcd",
UUID: "<randomly generated UUID>"
}
(Neutralino, response written in the stdOut)
{
type: "response",
UUID: "<UUID of the request>"
code: 404,
message: "The \"abcd\" function on \"Neutralino.window\" doesn't exist."
}
Here is the documentation on how to use this "protocol".
All request must define their "type" (function, event or generic) and must have a random UUID assigned (The UUID is used to get the correct response from the receiver).
function: Execute a function, while also passing the
params
key containing the function parameters.
{
type: "function",
function: "myfunctionName",
params: [0,"hello world"],
UUID: "<uuid>"
}
event: Triggers an event, while also passing the
data
key containing the data of the event.
{
type: "event",
event: "myeventname",
data: { lol: "cat" },
UUID: "<uuid>"
}
generic: Just for passing any messages.
{ isBall: "baller" }
...or simply a string
Hello world
All responses follow this pattern:
{
type: "response",
code: <any number code, ex: 404 or 200>,
message: "<the response message, ex: Action successful>",
UUID: "<optional uuid to let the sender know, from which request this response comes from>"
}