-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: launchApp as registered ipc handler
Add launchApp as a registered ipc handler, which will allow communication between iframes (apps/puter.js) to be simplified.
- Loading branch information
1 parent
813ee95
commit 7249429
Showing
4 changed files
with
53 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { Service } from "../definitions.js"; | ||
import launch_app from "../helpers/launch_app.js"; | ||
|
||
export class ExecService extends Service { | ||
async _init ({ services }) { | ||
const svc_ipc = services.get('ipc'); | ||
svc_ipc.register_ipc_handler('launchApp', { | ||
handler: this.launchApp.bind(this), | ||
}); | ||
} | ||
|
||
launchApp ({ app_name, args }, { ipc_context, msg_id } = {}) { | ||
const child_instance_id = window.uuidv4(); | ||
window.child_launch_callbacks[child_instance_id] = { | ||
parent_instance_id: event.data.appInstanceID, | ||
launch_msg_id: msg_id, | ||
}; | ||
// launch child app | ||
launch_app({ | ||
name: app_name, | ||
args: args ?? {}, | ||
parent_instance_id: ipc_context?.appInstanceId, | ||
uuid: child_instance_id, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Service } from "../definitions.js"; | ||
|
||
export class IPCService extends Service { | ||
async _init () { | ||
// | ||
} | ||
|
||
register_ipc_handler (name, spec) { | ||
window.ipc_handlers[name] = spec; | ||
} | ||
} |