mirror of
https://github.com/taigrr/wails.git
synced 2026-04-17 04:05:12 -07:00
Squashed 'v2/' content from commit 7d8960e
git-subtree-dir: v2 git-subtree-split: 7d8960e87431924f5705df4c777758a0eb32e145
This commit is contained in:
52
internal/runtime/js/server/ipc.js
Normal file
52
internal/runtime/js/server/ipc.js
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The lightweight framework for web-like apps
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
/* jshint esversion: 6 */
|
||||
|
||||
// IPC Listeners
|
||||
var listeners = [];
|
||||
|
||||
/**
|
||||
* Adds a listener to IPC messages
|
||||
* @param {function} callback
|
||||
*/
|
||||
export function AddIPCListener(callback) {
|
||||
listeners.push(callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoke sends the given message to the backend
|
||||
*
|
||||
* @param {string} message
|
||||
*/
|
||||
function Invoke(message) {
|
||||
if (window.wailsbridge && window.wailsbridge.websocket) {
|
||||
window.wailsbridge.websocket.send(JSON.stringify(message));
|
||||
} else {
|
||||
console.log('Invoke called with: ' + message + ' but no runtime is available');
|
||||
}
|
||||
|
||||
// Also send to listeners
|
||||
if (listeners.length > 0) {
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
listeners[i](message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to the backend based on the given type, payload and callbackID
|
||||
*
|
||||
* @export
|
||||
* @param {string} message
|
||||
*/
|
||||
|
||||
export function SendMessage(message) {
|
||||
Invoke(message);
|
||||
}
|
||||
21
internal/runtime/js/server/linux.js
Normal file
21
internal/runtime/js/server/linux.js
Normal file
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
_ __ _ __
|
||||
| | / /___ _(_) /____
|
||||
| | /| / / __ `/ / / ___/
|
||||
| |/ |/ / /_/ / / (__ )
|
||||
|__/|__/\__,_/_/_/____/
|
||||
The lightweight framework for web-like apps
|
||||
(c) Lea Anthony 2019-present
|
||||
*/
|
||||
/* jshint esversion: 6 */
|
||||
|
||||
/**
|
||||
* Initialises platform specific code
|
||||
*/
|
||||
|
||||
export const System = {
|
||||
Platform: "linux",
|
||||
AppType: "server"
|
||||
}
|
||||
|
||||
export function Init() { }
|
||||
Reference in New Issue
Block a user