2023-03-01 18:01:34 +08:00
|
|
|
//----------------------------------------
|
|
|
|
//
|
|
|
|
// Copyright © yanghy. All Rights Reserved.
|
|
|
|
//
|
|
|
|
// Licensed under Apache License Version 2.0, January 2004
|
|
|
|
//
|
|
|
|
// https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
//----------------------------------------
|
|
|
|
|
|
|
|
// application event 默认事件实现
|
|
|
|
package cef
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/energye/energy/common"
|
2023-03-02 18:47:39 +08:00
|
|
|
"github.com/energye/energy/consts"
|
|
|
|
)
|
|
|
|
|
2023-03-01 18:01:34 +08:00
|
|
|
// appOnContextCreated 创建应用上下文 - 默认实现
|
2023-03-02 18:47:39 +08:00
|
|
|
func appOnContextCreated(browser *ICefBrowser, frame *ICefFrame, context *ICefV8Context) {
|
2023-03-02 11:15:49 +08:00
|
|
|
fmt.Println("appOnContextCreated-ProcessTypeValue:", common.Args.ProcessType(), application.ProcessTypeValue(), "browserId:", browser.Identifier(), "frameId:", frame.Identifier())
|
2023-03-13 17:30:13 +08:00
|
|
|
ipcRender.makeCtx(context)
|
2023-03-03 12:52:00 +08:00
|
|
|
}
|
|
|
|
|
2023-03-03 17:08:06 +08:00
|
|
|
// appMainRunCallback 应用运行 - 默认实现
|
|
|
|
func appMainRunCallback() {
|
|
|
|
fmt.Println("appMainRunCallback-ProcessTypeValue:", common.Args.ProcessType(), application.ProcessTypeValue())
|
|
|
|
}
|
|
|
|
|
2023-03-13 17:30:13 +08:00
|
|
|
// renderProcessMessageReceived 渲染进程消息 - 默认实现
|
|
|
|
func renderProcessMessageReceived(browser *ICefBrowser, frame *ICefFrame, sourceProcess consts.CefProcessId, message *ICefProcessMessage) (result bool) {
|
2023-03-16 21:19:27 +08:00
|
|
|
return
|
2023-03-14 18:24:18 +08:00
|
|
|
if message.Name() == internalProcessMessageIPCEmitReply {
|
2023-03-14 17:41:30 +08:00
|
|
|
result = ipcRender.ipcJSExecuteGoEventMessageReply(browser, frame, sourceProcess, message)
|
2023-03-14 18:24:18 +08:00
|
|
|
} else if message.Name() == internalProcessMessageIPCOn {
|
2023-03-14 17:41:30 +08:00
|
|
|
result = ipcRender.ipcGoExecuteJSEvent(browser, frame, sourceProcess, message)
|
2023-03-13 16:48:40 +08:00
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2023-03-13 17:30:13 +08:00
|
|
|
// browserProcessMessageReceived 主进程消息 - 默认实现
|
|
|
|
func browserProcessMessageReceived(browser *ICefBrowser, frame *ICefFrame, sourceProcess consts.CefProcessId, message *ICefProcessMessage) (result bool) {
|
|
|
|
if message.Name() == internalProcessMessageIPCEmit {
|
2023-03-14 18:24:18 +08:00
|
|
|
result = ipcBrowser.ipcGoExecuteMethodMessage(browser, frame, sourceProcess, message)
|
2023-03-13 17:30:13 +08:00
|
|
|
} else if message.Name() == internalProcessMessageIPCOn {
|
|
|
|
result = ipcBrowser.ipcOnMessage(browser, frame, sourceProcess, message)
|
2023-03-15 14:29:45 +08:00
|
|
|
} else if message.Name() == internalProcessMessageIPCEmitReply {
|
|
|
|
result = ipcBrowser.ipcGoExecuteMethodMessageReply(browser, frame, sourceProcess, message)
|
2023-03-02 22:08:10 +08:00
|
|
|
}
|
2023-03-04 17:12:22 +08:00
|
|
|
return
|
2023-03-02 21:08:51 +08:00
|
|
|
}
|