channel

package
v2.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

README

Multi process IPC communication implemented in Go

introduction

based net socket & unix domain socket

Communication - Channel Selection

OS Version version IPC
windows < 10.17063 net socket
windows >= 10.17063 unix
linux all unix
macosx all unix

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MemoryAddress

func MemoryAddress() string

func Port

func Port() int

Port 获取并返回net socket端口

func SetPort

func SetPort(v int)

SetPort 设置 net socket 端口号, 如参数 "v" 非指定范围内端口则获取随机未使用端口号

v 1024 ~ 65535

func UseNetIPCChannel

func UseNetIPCChannel() bool

Types

type IBrowserChannel

type IBrowserChannel interface {
	Channel(channelId int64) IChannel
	ChannelIds() (result []int64)
	Send(channelId int64, data []byte)
	Handler(handler IPCCallback)
	Close()
}

func NewBrowser

func NewBrowser(addresses ...string) IBrowserChannel

NewBrowser Create main(browser) process channel

type IChannel

type IChannel interface {
	IsConnect() bool
	Close()
	// contains filtered or unexported methods
}

IChannel 通道链接

type IIPCContext

type IIPCContext interface {
	Connect() net.Conn        // IPC 通道链接
	ChannelId() int64         // 返回 发送通道ID
	ToChannelId() int64       // 返回 接收发送通道ID
	ChannelType() ChannelType // 返回 当前通道类型
	ProcessId() CefProcessId  // 返回 通道消息来源
	Message() IMessage        // 消息
	Free()                    //
}

IIPCContext IPC通信回调上下文

type IMessage

type IMessage interface {
	Type() mt        // 消息类型
	Length() int32   // 数据长度
	Data() []byte    // 数据
	JSON() json.JSON // 转为 JSON 对象并返回
	// contains filtered or unexported methods
}

IMessage 消息内容接口

type IPCCallback

type IPCCallback func(context IIPCContext)

IPCCallback 回调

type IPCContext

type IPCContext struct {
	// contains filtered or unexported fields
}

IPCContext IPC 上下文

func (*IPCContext) ChannelId

func (m *IPCContext) ChannelId() int64

ChannelId 返回发送通道ID

func (*IPCContext) ChannelType

func (m *IPCContext) ChannelType() ChannelType

ChannelType 返回当前通道类型

func (*IPCContext) Connect

func (m *IPCContext) Connect() net.Conn

Connect 返回当前通道链接

func (*IPCContext) Free

func (m *IPCContext) Free()

Free 释放消息内存空间

func (*IPCContext) Message

func (m *IPCContext) Message() IMessage

Message 返回消息内容

func (*IPCContext) ProcessId

func (m *IPCContext) ProcessId() CefProcessId

func (*IPCContext) ToChannelId

func (m *IPCContext) ToChannelId() int64

ToChannelId 返回接收通道ID

type IRenderChannel

type IRenderChannel interface {
	Channel() IChannel
	Send(data []byte)
	SendToChannel(toChannelId int64, data []byte)
	UpdateChannelId(toChannelId int64)
	Handler(handler IPCCallback)
	Close()
}

func NewRender

func NewRender(channelId int64, addresses ...string) IRenderChannel

NewRender Create the renderer process channel

param: channelId Unique channel ID identifier

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL