Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
9f1a4609
energy
项目概览
energye
/
energy
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
energy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9f1a4609
编写于
3月 16, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upgrade-dev v2.3.12
上级
c252fc61
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
110 addition
and
70 deletion
+110
-70
cef/cef-chromium-proc.go
cef/cef-chromium-proc.go
+48
-35
cef/cef-frame.go
cef/cef-frame.go
+40
-35
cef/cef-ipc.go
cef/cef-ipc.go
+6
-0
cef/cef-proc-def.go
cef/cef-proc-def.go
+16
-0
未找到文件。
cef/cef-chromium-proc.go
浏览文件 @
9f1a4609
...
...
@@ -726,6 +726,7 @@ func (m *TCEFChromium) SendProcessMessage(targetProcess CefProcessId, message *I
message
.
Free
()
}
// SendProcessMessageForJSONBytes 发送进程消息
func
(
m
*
TCEFChromium
)
SendProcessMessageForJSONBytes
(
name
string
,
targetProcess
CefProcessId
,
message
json
.
JSONObject
)
{
if
!
m
.
initialized
{
m
.
initialized
=
m
.
Initialized
()
...
...
@@ -736,49 +737,30 @@ func (m *TCEFChromium) SendProcessMessageForJSONBytes(name string, targetProcess
message
.
Free
()
}
// SendProcessMessageForIPC IPC 发送进程 消息
//
// messageId != 0 是带有回调函数消息
func
(
m
*
TCEFChromium
)
SendProcessMessageForIPC
(
messageId
int32
,
eventName
string
,
targetProcess
CefProcessId
,
target
ipc
.
ITarget
,
data
...
any
)
{
if
!
m
.
initialized
{
m
.
initialized
=
m
.
Initialized
()
return
}
message
:=
json
.
NewJSONObject
(
nil
)
message
.
Set
(
"id"
,
messageId
)
message
.
Set
(
"event"
,
eventName
)
argumentJSONArray
:=
json
.
NewJSONArray
(
nil
)
for
_
,
result
:=
range
data
{
switch
result
.
(
type
)
{
case
error
:
argumentJSONArray
.
Add
(
result
.
(
error
)
.
Error
())
default
:
argumentJSONArray
.
Add
(
result
)
}
}
message
.
Set
(
"argumentList"
,
argumentJSONArray
)
m
.
SendProcessMessageForJSONBytes
(
internalProcessMessageIPCOn
,
targetProcess
,
message
)
return
if
target
==
nil
||
target
.
GetBrowserId
()
<=
0
||
target
.
GetFrameId
()
<=
0
{
message
:=
ProcessMessageRef
.
new
(
internalProcessMessageIPCOn
)
argument
:=
message
.
ArgumentList
()
argument
.
SetInt
(
0
,
messageId
)
argument
.
SetString
(
1
,
eventName
)
if
data
!=
nil
&&
len
(
data
)
>
0
{
argumentJSONArray
:=
json
.
NewJSONArray
(
nil
)
for
_
,
result
:=
range
data
{
switch
result
.
(
type
)
{
case
error
:
argumentJSONArray
.
Add
(
result
.
(
error
)
.
Error
())
default
:
argumentJSONArray
.
Add
(
result
)
}
message
:=
json
.
NewJSONObject
(
nil
)
message
.
Set
(
ipc_id
,
messageId
)
message
.
Set
(
ipc_event
,
eventName
)
argumentJSONArray
:=
json
.
NewJSONArray
(
nil
)
for
_
,
result
:=
range
data
{
switch
result
.
(
type
)
{
case
error
:
argumentJSONArray
.
Add
(
result
.
(
error
)
.
Error
())
default
:
argumentJSONArray
.
Add
(
result
)
}
binaryValue
:=
BinaryValueRef
.
New
(
argumentJSONArray
.
Bytes
())
argument
.
SetBinary
(
2
,
binaryValue
)
argumentJSONArray
.
Free
()
}
m
.
SendProcessMessage
(
targetProcess
,
message
)
message
.
Set
(
ipc_argumentList
,
argumentJSONArray
)
m
.
SendProcessMessageForJSONBytes
(
internalProcessMessageIPCOn
,
targetProcess
,
message
)
}
else
{
browse
:=
m
.
BrowserById
(
target
.
GetBrowserId
())
if
browse
.
IsValid
()
{
...
...
@@ -788,6 +770,37 @@ func (m *TCEFChromium) SendProcessMessageForIPC(messageId int32, eventName strin
}
}
}
//return
//if target == nil || target.GetBrowserId() <= 0 || target.GetFrameId() <= 0 {
// message := ProcessMessageRef.new(internalProcessMessageIPCOn)
// argument := message.ArgumentList()
// argument.SetInt(0, messageId)
// argument.SetString(1, eventName)
// if data != nil && len(data) > 0 {
// argumentJSONArray := json.NewJSONArray(nil)
// for _, result := range data {
// switch result.(type) {
// case error:
// argumentJSONArray.Add(result.(error).Error())
// default:
// argumentJSONArray.Add(result)
// }
// }
// binaryValue := BinaryValueRef.New(argumentJSONArray.Bytes())
// argument.SetBinary(2, binaryValue)
// argumentJSONArray.Free()
// }
// m.SendProcessMessage(targetProcess, message)
//} else {
// browse := m.BrowserById(target.GetBrowserId())
// if browse.IsValid() {
// frame := browse.GetFrameById(target.GetFrameId())
// if frame.IsValid() {
// frame.SendProcessMessageForIPC(messageId, eventName, targetProcess, target, data)
// }
// }
//}
}
//--------TCEFChromium proc begin--------
...
...
cef/cef-frame.go
浏览文件 @
9f1a4609
...
...
@@ -96,52 +96,57 @@ func (m *ICefFrame) IsFocused() bool {
return
api
.
GoBool
(
r1
)
}
//// SendProcessMessageByIPC 发送进程消息
//func (m *ICefFrame) SendProcessMessageByIPC(targetProcess CefProcessId, processMessage *ipc.ICefProcessMessage) ProcessMessageError {
// if processMessage == nil || processMessage.Name == "" || processMessage.ArgumentList == nil {
// return PMErr_REQUIRED_PARAMS_IS_NULL
// } else if ipc.InternalIPCNameCheck(processMessage.Name) {
// return PMErr_NAME_CANNOT_USED
// }
// data := processMessage.ArgumentList.Package()
// r1 := _CEFFrame_SendProcessMessageByIPC(m.Browser.Identifier(), m.Id, processMessage.Name, targetProcess, int32(processMessage.ArgumentList.Size()), uintptr(unsafe.Pointer(&data[0])), uintptr(len(data)))
// return ProcessMessageError(r1)
//}
//
//func _CEFFrame_SendProcessMessageByIPC(browseId int32, frameId int64, name string, targetProcess CefProcessId, itemLength int32, data, dataLen uintptr) uintptr {
// r1, _, _ := imports.Proc(internale_CEFFrame_SendProcessMessageByIPC).Call(uintptr(browseId), uintptr(unsafe.Pointer(&frameId)), api.PascalStr(name), uintptr(targetProcess), uintptr(itemLength), data, dataLen)
// return r1
//}
// SendProcessMessage 发送进程消息
func
(
m
*
ICefFrame
)
SendProcessMessage
(
targetProcess
CefProcessId
,
message
*
ICefProcessMessage
)
{
imports
.
Proc
(
internale_CEFFrame_SendProcessMessage
)
.
Call
(
m
.
Instance
(),
targetProcess
.
ToPtr
(),
message
.
Instance
())
message
.
Free
()
}
// SendProcessMessageForJSONBytes 发送进程消息
func
(
m
*
ICefFrame
)
SendProcessMessageForJSONBytes
(
name
string
,
targetProcess
CefProcessId
,
message
json
.
JSONObject
)
{
var
data
=
message
.
Bytes
()
imports
.
Proc
(
internale_CEFFrame_SendProcessMessageForJSONBytes
)
.
Call
(
m
.
Instance
(),
api
.
PascalStr
(
name
),
targetProcess
.
ToPtr
(),
uintptr
(
unsafe
.
Pointer
(
&
data
[
0
])),
uintptr
(
uint32
(
len
(
data
))))
message
.
Free
()
}
// SendProcessMessageForIPC IPC 发送进程 消息
//
// messageId != 0 是带有回调函数消息
func
(
m
*
ICefFrame
)
SendProcessMessageForIPC
(
messageId
int32
,
n
ame
string
,
targetProcess
CefProcessId
,
target
ipc
.
ITarget
,
data
...
any
)
{
message
:=
ProcessMessageRef
.
new
(
internalProcessMessageIPCOn
)
if
data
!=
nil
&&
len
(
data
)
>
0
{
argumentJSONArray
:=
json
.
NewJSONArray
(
nil
)
for
_
,
result
:=
range
data
{
switch
result
.
(
type
)
{
case
error
:
argumentJSONArray
.
Add
(
result
.
(
error
)
.
Error
())
default
:
argumentJSONArray
.
Add
(
result
)
}
func
(
m
*
ICefFrame
)
SendProcessMessageForIPC
(
messageId
int32
,
eventN
ame
string
,
targetProcess
CefProcessId
,
target
ipc
.
ITarget
,
data
...
any
)
{
message
:=
json
.
NewJSONObject
(
nil
)
message
.
Set
(
ipc_id
,
messageId
)
message
.
Set
(
ipc_event
,
eventName
)
argumentJSONArray
:=
json
.
NewJSONArray
(
nil
)
for
_
,
result
:=
range
data
{
switch
result
.
(
type
)
{
case
error
:
argumentJSONArray
.
Add
(
result
.
(
error
)
.
Error
())
default
:
argumentJSONArray
.
Add
(
result
)
}
argument
:=
message
.
ArgumentList
()
argument
.
SetInt
(
0
,
messageId
)
argument
.
SetString
(
1
,
name
)
binaryValue
:=
BinaryValueRef
.
New
(
argumentJSONArray
.
Bytes
())
argument
.
SetBinary
(
2
,
binaryValue
)
argumentJSONArray
.
Free
()
}
m
.
SendProcessMessage
(
targetProcess
,
message
)
message
.
Set
(
ipc_argumentList
,
argumentJSONArray
)
m
.
SendProcessMessageForJSONBytes
(
internalProcessMessageIPCOn
,
targetProcess
,
message
)
//return
//message := ProcessMessageRef.new(internalProcessMessageIPCOn)
//if data != nil && len(data) > 0 {
// argumentJSONArray := json.NewJSONArray(nil)
// for _, result := range data {
// switch result.(type) {
// case error:
// argumentJSONArray.Add(result.(error).Error())
// default:
// argumentJSONArray.Add(result)
// }
// }
// argument := message.ArgumentList()
// argument.SetInt(0, messageId)
// argument.SetString(1, name)
// binaryValue := BinaryValueRef.New(argumentJSONArray.Bytes())
// argument.SetBinary(2, binaryValue)
// argumentJSONArray.Free()
//}
//m.SendProcessMessage(targetProcess, message)
}
func
(
m
*
ICefFrame
)
LoadRequest
(
request
*
ICefRequest
)
{
...
...
cef/cef-ipc.go
浏览文件 @
9f1a4609
...
...
@@ -27,6 +27,12 @@ const (
internalProcessMessageIPCOn
=
"onHandler"
// 进程消息 on监听事件处理
)
const
(
ipc_id
=
"id"
ipc_event
=
"event"
ipc_argumentList
=
"argumentList"
)
var
(
internalObjectRootName
=
"energy"
// GO 和 V8Value 绑定根对象名
ipcRender
*
ipcRenderProcess
//渲染进程 IPC
...
...
cef/cef-proc-def.go
浏览文件 @
9f1a4609
...
...
@@ -614,6 +614,7 @@ func init() {
dllimports
.
NewEnergyImport
(
"CEFFrame_IsMain"
,
0
),
dllimports
.
NewEnergyImport
(
"CEFFrame_IsFocused"
,
0
),
dllimports
.
NewEnergyImport
(
"CEFFrame_SendProcessMessage"
,
0
),
dllimports
.
NewEnergyImport
(
"CEFFrame_SendProcessMessageForJSONBytes"
,
0
),
dllimports
.
NewEnergyImport
(
"CEFFrame_LoadRequest"
,
0
),
dllimports
.
NewEnergyImport
(
"CEFFrame_Browser"
,
0
),
dllimports
.
NewEnergyImport
(
"CEFFrame_GetV8Context"
,
0
),
...
...
@@ -1096,6 +1097,13 @@ func init() {
dllimports
.
NewEnergyImport
(
"CefCommandLine_GetArguments"
,
0
),
dllimports
.
NewEnergyImport
(
"CefCommandLine_AppendArgument"
,
0
),
dllimports
.
NewEnergyImport
(
"CefCommandLine_PrependWrapper"
,
0
),
//TValueConvert
dllimports
.
NewEnergyImport
(
"ValueConvert_BytesToProcessMessage"
,
0
),
dllimports
.
NewEnergyImport
(
"ValueConvert_BytesToListValue"
,
0
),
dllimports
.
NewEnergyImport
(
"ValueConvert_BytesToDictionaryValue"
,
0
),
dllimports
.
NewEnergyImport
(
"ValueConvert_BytesToV8ValueArray"
,
0
),
dllimports
.
NewEnergyImport
(
"ValueConvert_BytesToV8Array"
,
0
),
dllimports
.
NewEnergyImport
(
"ValueConvert_BytesToV8Object"
,
0
),
}
imports
.
SetEnergyImportDefs
(
energyImportDefs
)
}
...
...
@@ -1697,6 +1705,7 @@ const (
internale_CEFFrame_IsMain
internale_CEFFrame_IsFocused
internale_CEFFrame_SendProcessMessage
internale_CEFFrame_SendProcessMessageForJSONBytes
internale_CEFFrame_LoadRequest
internale_CEFFrame_Browser
internale_CEFFrame_GetV8Context
...
...
@@ -2179,4 +2188,11 @@ const (
internale_CefCommandLine_GetArguments
internale_CefCommandLine_AppendArgument
internale_CefCommandLine_PrependWrapper
//TValueConvert
internale_ValueConvert_BytesToProcessMessage
internale_ValueConvert_BytesToListValue
internale_ValueConvert_BytesToDictionaryValue
internale_ValueConvert_BytesToV8ValueArray
internale_ValueConvert_BytesToV8Array
internale_ValueConvert_BytesToV8Object
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录