core

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadDevices

func LoadDevices(ctx context.Context) error

func LoadProduct

func LoadProduct(ctx context.Context, id string) (*model.Product, error)

func LoadServer

func LoadServer(ctx context.Context, id int) error

LoadServer 启动时候加载服务

func LoadServers

func LoadServers(ctx context.Context) error

LoadServers 启动时候加载服务

func LoadTunnel

func LoadTunnel(ctx context.Context, id int) error

func LoadTunnels

func LoadTunnels(ctx context.Context) error

func MapperDevice

func MapperDevice(res logicModel.DeviceOutput) model.Device

func MapperServer

func MapperServer(ctx context.Context, res logicModel.NetworkServerOut) model.Server

todo 需要处理下心跳和注册包,需要考虑到客户端可能不支持心跳或者注册包

func NewTunnel

func NewTunnel(tunnel *model.Tunnel) (tunnelinstance.TunnelInstance, error)

NewTunnel 创建通道

func RemoveDevice

func RemoveDevice(id uint64) error

func RemoveServer

func RemoveServer(id int) error

func RemoveTunnel

func RemoveTunnel(id int) error

func ServerCloseAction

func ServerCloseAction(serverId int)

func ServerOpenAction

func ServerOpenAction(serverId int)

func ServerTunnelAction

func ServerTunnelAction(ctx context.Context, serverId int, deviceKey string)

func StartSubscriber

func StartSubscriber(ctx context.Context) error

func StrToPointInterfaceWithError

func StrToPointInterfaceWithError(str string, a interface{}) error

func StrToPointInterfaceWithoutError

func StrToPointInterfaceWithoutError(ctx context.Context, str string, a interface{})

func TunnelCloseAction

func TunnelCloseAction(tunnelId int)

func TunnelOfflineAction

func TunnelOfflineAction(ctx context.Context, serverId, tunnelId int)

func TunnelOnlineAction

func TunnelOnlineAction(ctx context.Context, tunnelId int, deviceKey string)

func TunnelOpenAction

func TunnelOpenAction(tunnelId int)

Types

type Device

type Device struct {
	model.Device
	events.EventEmitter

	Context map[string]interface{}
	// contains filtered or unexported fields
}

Device 设备

func GetDevice

func GetDevice(id uint64) *Device

func LoadDevice

func LoadDevice(ctx context.Context, id uint) (*Device, error)

func NewDevice

func NewDevice(ctx context.Context, m *model.Device) (*Device, error)

func (*Device) BindTunnel

func (dev *Device) BindTunnel(tunnel *Tunnel) error

func (*Device) Refresh

func (dev *Device) Refresh(ctx context.Context) error

func (*Device) Running

func (dev *Device) Running() bool

func (*Device) Start

func (dev *Device) Start(ctx context.Context) error

func (*Device) Stop

func (dev *Device) Stop() error

type MessagePropertyReporter

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

func (MessagePropertyReporter) DeviceDataHandle

func (m MessagePropertyReporter) DeviceDataHandle()

type Point

type Point struct {
	model.Point
}

type Poller

type Poller struct {
	model.Poller
	Device *Device
	// contains filtered or unexported fields
}

Poller 采集器

func (*Poller) Execute

func (p *Poller) Execute(ctx context.Context)

Execute 执行

func (*Poller) Start

func (p *Poller) Start(ctx context.Context) (err error)

Start 启动

func (*Poller) Stop

func (p *Poller) Stop()

Stop 结束

type Server

type Server struct {
	model.Server
	Instance ServerInstance
}

func GetServer

func GetServer(id int) *Server

GetServer 获取通道

type ServerInstance

type ServerInstance interface {
	Open(ctx context.Context) error
	Close() error
	GetTunnel(id int) tunnelinstance.TunnelInstance
	RemoveTunnel(id int)
	Running() bool
}

Server 通道

func NewServer

func NewServer(server *model.Server) (ServerInstance, error)

NewServer 创建通道

type ServerTCP

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

func (*ServerTCP) Close

func (server *ServerTCP) Close() (err error)

func (*ServerTCP) GetTunnel

func (server *ServerTCP) GetTunnel(id int) tunnelinstance.TunnelInstance

func (*ServerTCP) Open

func (server *ServerTCP) Open(ctx context.Context) error

func (*ServerTCP) RemoveTunnel

func (server *ServerTCP) RemoveTunnel(id int)

func (*ServerTCP) Running

func (server *ServerTCP) Running() bool

type ServerTcpTunnel

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

ServerTcpTunnel 网络连接

func (*ServerTcpTunnel) Ask

func (l *ServerTcpTunnel) Ask(cmd []byte, timeout time.Duration) ([]byte, error)

func (*ServerTcpTunnel) Close

func (l *ServerTcpTunnel) Close() error

Close 关闭

func (*ServerTcpTunnel) Online

func (l *ServerTcpTunnel) Online() bool

func (*ServerTcpTunnel) Open

func (l *ServerTcpTunnel) Open(ctx context.Context) error

func (*ServerTcpTunnel) Pipe

func (l *ServerTcpTunnel) Pipe(pipe io.ReadWriteCloser)

func (*ServerTcpTunnel) ReadData

func (l *ServerTcpTunnel) ReadData(ctx context.Context, deviceKey string, data []byte)

func (*ServerTcpTunnel) Running

func (l *ServerTcpTunnel) Running() bool

func (*ServerTcpTunnel) Write

func (l *ServerTcpTunnel) Write(data []byte) error

Write 写

type ServerUDP

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

ServerUDP UDP服务器

func (*ServerUDP) Close

func (server *ServerUDP) Close() (err error)

Close 关闭

func (*ServerUDP) GetTunnel

func (server *ServerUDP) GetTunnel(id int) tunnelinstance.TunnelInstance

GetTunnel 获取链接

func (*ServerUDP) Open

func (server *ServerUDP) Open(ctx context.Context) error

Open 打开

func (*ServerUDP) RemoveTunnel

func (server *ServerUDP) RemoveTunnel(id int)

func (*ServerUDP) Running

func (server *ServerUDP) Running() bool

type ServerUdpTunnel

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

ServerUdpTunnel UDP链接

func (*ServerUdpTunnel) Ask

func (l *ServerUdpTunnel) Ask(cmd []byte, timeout time.Duration) ([]byte, error)

func (*ServerUdpTunnel) Close

func (l *ServerUdpTunnel) Close() error

func (*ServerUdpTunnel) Online

func (l *ServerUdpTunnel) Online() bool

func (*ServerUdpTunnel) Open

func (l *ServerUdpTunnel) Open(ctx context.Context) error

func (*ServerUdpTunnel) Pipe

func (l *ServerUdpTunnel) Pipe(pipe io.ReadWriteCloser)

func (*ServerUdpTunnel) ReadData

func (l *ServerUdpTunnel) ReadData(ctx context.Context, deviceKey string, data []byte)

func (*ServerUdpTunnel) Running

func (l *ServerUdpTunnel) Running() bool

func (*ServerUdpTunnel) Write

func (l *ServerUdpTunnel) Write(data []byte) error

Write 写

type Tunnel

type Tunnel struct {
	Instance tunnelinstance.TunnelInstance
}

func GetTunnel

func GetTunnel(id int) *Tunnel

type TunnelClient

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

TunnelClient 网络链接

func (*TunnelClient) Ask

func (l *TunnelClient) Ask(cmd []byte, timeout time.Duration) ([]byte, error)

func (*TunnelClient) Close

func (client *TunnelClient) Close() error

Close 关闭

func (*TunnelClient) Online

func (l *TunnelClient) Online() bool

func (*TunnelClient) Open

func (client *TunnelClient) Open(ctx context.Context) error

Open 打开

func (*TunnelClient) Pipe

func (l *TunnelClient) Pipe(pipe io.ReadWriteCloser)

func (*TunnelClient) ReadData

func (l *TunnelClient) ReadData(ctx context.Context, deviceKey string, data []byte)

func (*TunnelClient) Retry

func (client *TunnelClient) Retry(ctx context.Context)

func (*TunnelClient) Running

func (l *TunnelClient) Running() bool

func (*TunnelClient) Write

func (l *TunnelClient) Write(data []byte) error

Write 写

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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