upgrade-dev v2.3.28

This commit is contained in:
杨红岩 2023-03-23 18:56:25 +08:00
parent 43d1659127
commit 7f1f73a831
3 changed files with 24 additions and 24 deletions

View File

@ -28,13 +28,13 @@ func (m *ipcBrowserProcess) ipcChannelBrowser() {
m.ipcChannel.ipc = channel.NewBrowser()
m.ipcChannel.ipc.Handler(func(context channel.IIPCContext) {
messageJSON := context.Message().JSON().JSONObject()
messageId := messageJSON.GetIntByKey(ipc_id)
//messageId := messageJSON.GetIntByKey(ipc_id)// messageId: 同步永远是1
emitName := messageJSON.GetStringByKey(ipc_event)
name := messageJSON.GetStringByKey(ipc_name)
browserId := messageJSON.GetIntByKey(ipc_browser_id)
argumentList := messageJSON.GetArrayByKey(ipc_argumentList)
if name == internalIPCJSExecuteGoSyncEvent {
m.jsExecuteGoSyncMethodMessage(int32(messageId), int32(browserId), context.ChannelId(), emitName, argumentList)
m.jsExecuteGoSyncMethodMessage(int32(browserId), context.ChannelId(), emitName, argumentList)
}
context.Free()
})
@ -42,27 +42,26 @@ func (m *ipcBrowserProcess) ipcChannelBrowser() {
}
// jsExecuteGoSyncMethodMessage JS执行Go事件 - 同步消息处理
func (m *ipcBrowserProcess) jsExecuteGoSyncMethodMessage(messageId, browserId int32, frameId int64, emitName string, argumentList json.JSONArray) {
func (m *ipcBrowserProcess) jsExecuteGoSyncMethodMessage(browserId int32, frameId int64, emitName string, argumentList json.JSONArray) {
var ipcContext = m.jsExecuteGoMethod(browserId, frameId, emitName, argumentList)
if messageId != 0 { // 同步回调函数处理
message := json.NewJSONObject(nil)
message.Set(ipc_id, messageId)
message.Set(ipc_name, internalIPCJSExecuteGoSyncEventReplay)
message.Set(ipc_argumentList, nil)
if ipcContext != nil {
//处理回复消息
replay := ipcContext.Replay()
if replay.Result() != nil && len(replay.Result()) > 0 {
switch replay.Result()[0].(type) {
case []byte:
message.Set(ipc_argumentList, json.NewJSONArray((replay.Result()[0]).([]byte)).Data())
}
message := json.NewJSONObject(nil)
message.Set(ipc_id, 1)
message.Set(ipc_name, internalIPCJSExecuteGoSyncEventReplay)
message.Set(ipc_argumentList, nil)
// 同步回调函数处理
if ipcContext != nil {
//处理回复消息
replay := ipcContext.Replay()
if replay.Result() != nil && len(replay.Result()) > 0 {
switch replay.Result()[0].(type) {
case []byte:
message.Set(ipc_argumentList, json.NewJSONArray((replay.Result()[0]).([]byte)).Data())
}
}
//回复结果消息
m.ipcChannel.ipc.Send(frameId, message.Bytes())
message.Free()
}
//回复结果消息
m.ipcChannel.ipc.Send(frameId, message.Bytes())
message.Free()
if ipcContext != nil {
if ipcContext.ArgumentList() != nil {
ipcContext.ArgumentList().Free()

View File

@ -32,11 +32,11 @@ func (m *ipcRenderProcess) ipcChannelRender(browser *ICefBrowser, frame *ICefFra
m.ipcChannel.ipc = channel.NewRender(m.ipcChannel.frameId)
m.ipcChannel.ipc.Handler(func(context channel.IIPCContext) {
messageJSON := context.Message().JSON().JSONObject()
messageId := messageJSON.GetIntByKey(ipc_id)
//messageId := messageJSON.GetIntByKey(ipc_id)// messageId: 同步永远是1
name := messageJSON.GetStringByKey(ipc_name)
argumentList := messageJSON.GetArrayByKey(ipc_argumentList)
if name == internalIPCJSExecuteGoSyncEventReplay {
m.ipcJSExecuteGoSyncEventMessageReply(int32(messageId), argumentList)
m.ipcJSExecuteGoSyncEventMessageReply(argumentList)
}
context.Free()
})
@ -44,7 +44,7 @@ func (m *ipcRenderProcess) ipcChannelRender(browser *ICefBrowser, frame *ICefFra
}
// ipcJSExecuteGoSyncEventMessageReply JS执行Go事件 - 同步回复接收
func (m *ipcRenderProcess) ipcJSExecuteGoSyncEventMessageReply(messageId int32, argumentList json.JSONArray) {
func (m *ipcRenderProcess) ipcJSExecuteGoSyncEventMessageReply(argumentList json.JSONArray) {
if argumentList != nil {
m.syncChan.resultSyncChan <- argumentList
} else {

View File

@ -285,8 +285,9 @@
function testEmitSync() {
//let result = ipc.emitSync("testEmitSync", ["同步参数", 1, 2, 3, ["aaaa", "bbb", 6666]])
//msg("testEmitSync", result);
let result = ipc.emitSync("testEmitSync", ["同步参数", 1, 2, 3, ["aaaa", "bbb", 6666]])
clearMsg()
msg("testEmitSync", result);
ipc.emitSync("testEmitSync", ["同步参数", 1, 2, 3, ["aaaa", "bbb", 6666]], function (result) {
msg("testEmitSync-callback", result);
})