upgrade-dev v2.3.25

This commit is contained in:
杨红岩 2023-03-23 11:46:34 +08:00
parent ab3e7a1435
commit 417bdd3c06
5 changed files with 70 additions and 30 deletions

View File

@ -17,11 +17,13 @@ import (
// appOnContextCreated 创建应用上下文 - 默认实现
func appOnContextCreated(browser *ICefBrowser, frame *ICefFrame, context *ICefV8Context) {
ipcRender.ipcChannelRender(browser, frame)
ipcRender.makeIPC(browser, frame, context)
}
// appMainRunCallback 应用运行 - 默认实现
func appMainRunCallback() {
ipcBrowser.ipcChannelBrowser()
}
// renderProcessMessageReceived 渲染进程消息 - 默认实现

View File

@ -0,0 +1,29 @@
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
// GO browser IPC通道
package cef
import "github.com/energye/energy/pkgs/channel"
// browserIPCChan
type browserIPCChan struct {
ipc channel.IBrowserChannel
}
func (m *ipcBrowserProcess) ipcChannelBrowser() {
if m.ipcChannel == nil {
m.ipcChannel = new(browserIPCChan)
m.ipcChannel.ipc = channel.NewBrowser()
m.ipcChannel.ipc.Handler(func(context channel.IIPCContext) {
context.Free()
})
}
}

View File

@ -14,7 +14,6 @@ package cef
import (
"github.com/energye/energy/consts"
"github.com/energye/energy/ipc"
"github.com/energye/energy/pkgs/channel"
"github.com/energye/energy/pkgs/json"
)
@ -23,16 +22,7 @@ type ipcBrowserProcess struct {
ipcObject *ICefV8Value // ipc object
emitHandler *ipcEmitHandler // ipc.emit handler
onHandler *ipcOnHandler // ipc.on handler
ipcChannel channel.IBrowserChannel
}
func (m *ipcBrowserProcess) ipcChannelBrowser() {
if m.ipcChannel == nil {
m.ipcChannel = channel.NewBrowser()
m.ipcChannel.Handler(func(context channel.IIPCContext) {
context.Free()
})
}
ipcChannel *browserIPCChan // channel
}
// ipcGoExecuteMethodMessage 执行 Go 监听函数

View File

@ -0,0 +1,33 @@
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
// GO render IPC通道
package cef
import "github.com/energye/energy/pkgs/channel"
// renderIPCChan
type renderIPCChan struct {
browserId int32
frameId int64
ipc channel.IRenderChannel //channel
}
func (m *ipcRenderProcess) ipcChannelRender(browser *ICefBrowser, frame *ICefFrame) {
if m.ipcChannel == nil {
m.ipcChannel = new(renderIPCChan)
m.ipcChannel.browserId = browser.Identifier()
m.ipcChannel.frameId = frame.Identifier()
m.ipcChannel.ipc = channel.NewRender(m.ipcChannel.frameId)
m.ipcChannel.ipc.Handler(func(context channel.IIPCContext) {
context.Free()
})
}
}

View File

@ -14,20 +14,17 @@ package cef
import (
"fmt"
"github.com/energye/energy/consts"
"github.com/energye/energy/pkgs/channel"
"github.com/energye/energy/pkgs/json"
"time"
)
// ipcRenderProcess 渲染进程
type ipcRenderProcess struct {
bind *ICefV8Value // go bind
ipcObject *ICefV8Value // ipc object
emitHandler *ipcEmitHandler // ipc.emit handler
onHandler *ipcOnHandler // ipc.on handler
ipcChannel channel.IRenderChannel //channel
browserId int32
frameId int64
bind *ICefV8Value // go bind
ipcObject *ICefV8Value // ipc object
emitHandler *ipcEmitHandler // ipc.emit handler
onHandler *ipcOnHandler // ipc.on handler
ipcChannel *renderIPCChan // channel
v8Context *ICefV8Context
}
@ -49,17 +46,6 @@ func (m *ipcRenderProcess) clear() {
}
}
func (m *ipcRenderProcess) ipcChannelRender(browser *ICefBrowser, frame *ICefFrame) {
if m.ipcChannel == nil {
m.browserId = browser.Identifier()
m.frameId = frame.Identifier()
m.ipcChannel = channel.NewRender(m.frameId)
m.ipcChannel.Handler(func(context channel.IIPCContext) {
context.Free()
})
}
}
func (m *ipcRenderProcess) initEventGlobal() {
if m.v8Context == nil {
m.v8Context = V8ContextRef.Current()