Skip to content

How does the frontend and backend communicate (in prod build)? #1809

Answered by leaanthony
snluu asked this question in Q&A
Discussion options

You must be logged in to vote

Good question! It uses an internal IPC mechanism built into the webviews. All the bound methods in JS are wrappers to this function: https://github.com/wailsapp/wails/blob/master/v2/internal/frontend/runtime/desktop/calls.js#L57
WailsInvoke is the build agnostic method to pass a message to the host application. For prod builds that's this: https://github.com/wailsapp/wails/blob/master/v2/internal/frontend/runtime/desktop/ipc.js
For Dev mode, it's sent over a websocket as defined here: https://github.com/wailsapp/wails/blob/master/v2/internal/frontend/runtime/dev/main.js#L21
So that's the JS side.
For Go, there's a listener setup to receive these messages. For prod builds, a platform speci…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by snluu
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants