diff --git a/ipc/ipc-channel-browser.go b/ipc/ipc-channel-browser.go index 10257d6b..89c35422 100644 --- a/ipc/ipc-channel-browser.go +++ b/ipc/ipc-channel-browser.go @@ -109,7 +109,7 @@ func (m *browserChannel) Close() { } } -func (m *browserChannel) onConnect(context IPCContext) { +func (m *browserChannel) onConnect(context IIPCContext) { logger.Info("IPC browser on connect channelId:", context.ChannelId()) if chn := m.Channel(context.ChannelId()); chn != nil { chn.IPCType = m.ipcType @@ -200,6 +200,7 @@ func (m *browserChannel) ipcReadHandler(conn net.Conn) { if context.Message().Type() == mt_connection { message := json.NewJSONObject(context.Message().Data()) id = int64(message.GetIntByKey(channelId)) + m.onConnect(context) } else { if m.handler != nil { m.handler(context) diff --git a/ipc/ipc-channel-render.go b/ipc/ipc-channel-render.go index 68c43962..6aa02944 100644 --- a/ipc/ipc-channel-render.go +++ b/ipc/ipc-channel-render.go @@ -20,7 +20,6 @@ import ( ) type renderChannel struct { - browserId int32 channelId int64 ipcType IPC_TYPE connect net.Conn @@ -29,7 +28,7 @@ type renderChannel struct { handler IPCCallback } -func (m *ipcChannel) NewRenderChannel(browserId int32, channelId int64, memoryAddresses ...string) *renderChannel { +func (m *ipcChannel) NewRenderChannel(channelId int64, memoryAddresses ...string) *renderChannel { if useNetIPCChannel { address := fmt.Sprintf("localhost:%d", IPC.Port()) conn, err := net.Dial("tcp", address) @@ -55,7 +54,6 @@ func (m *ipcChannel) NewRenderChannel(browserId int32, channelId int64, memoryAd m.render.ipcType = IPCT_UNIX m.render.connect = unixConn } - m.render.browserId = browserId m.render.channelId = channelId go m.render.receive() m.render.onConnection() diff --git a/ipc/ipc-channel.go b/ipc/ipc-channel.go index 8e181be2..4e1503c1 100644 --- a/ipc/ipc-channel.go +++ b/ipc/ipc-channel.go @@ -126,7 +126,6 @@ type messageCallback func(context IMessage) type IIPCContext interface { Connect() net.Conn //IPC 链接 ChannelId() int64 //render channel channelId - BrowserId() int32 //render channel browserId Message() IMessage // Free() // } @@ -154,8 +153,7 @@ type ipcMessage struct { // IPC 上下文 type IPCContext struct { - browserId int32 //render channel browserId - frameId int64 //render channel frameId + channelId int64 //render channelId ipcType IPC_TYPE // connect net.Conn // message IMessage // @@ -185,11 +183,7 @@ func (m *IPCContext) Free() { } func (m *IPCContext) ChannelId() int64 { - return m.frameId -} - -func (m *IPCContext) BrowserId() int32 { - return m.browserId + return m.channelId } func (m *IPCContext) Message() IMessage {