stream

package
v1.18.4 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetIOLog added in v1.16.3

func SetIOLog(enable bool)

func WithPacketProcessor

func WithPacketProcessor(pp PacketProcessor) func(s *SessionCtx)

func WithReact

func WithReact() func(s *SessionCtx)

Types

type HeaderTailPacketProcessor

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

HeaderTailPacketProcessor 固定包头包尾分包器

func (*HeaderTailPacketProcessor) Data

func (spp *HeaderTailPacketProcessor) Data(data []byte) (n int)

func (*HeaderTailPacketProcessor) Listen

func (spp *HeaderTailPacketProcessor) Listen(onPacket func(p []byte))

type Option

type Option func(s *SessionCtx)

type PacketProcessor

type PacketProcessor interface {
	Listen(onPacket func(p []byte))
	Data(data []byte) (n int)
}

func NewHeadTailPP

func NewHeadTailPP(head []byte, tail []byte) (pp PacketProcessor)

func NewSplitPP

func NewSplitPP(split byte) (pp PacketProcessor)

type Session

type Session interface {
	OnData(p []byte, size int, err error)
	Read(p []byte) (size int, err error)
	Write(p []byte) (size int, err error)
	OnIOErr(err func(interface{}))
}

func NewSerialSession

func NewSerialSession(ctx context.Context, name string, baud int, opts ...Option) (s Session, err error)

func NewSession

func NewSession(ctx context.Context, rwc io.ReadWriter, opts ...Option) (s Session)

type SessionCtx

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

func (*SessionCtx) OnData

func (s *SessionCtx) OnData(p []byte, size int, err error)

func (*SessionCtx) OnIOErr added in v1.16.1

func (s *SessionCtx) OnIOErr(errHandler func(interface{}))

func (*SessionCtx) Read

func (s *SessionCtx) Read(p []byte) (size int, err error)

func (*SessionCtx) Write

func (s *SessionCtx) Write(p []byte) (size int, err error)

type SplitPacketProcessor

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

SplitPacketProcessor 分隔符分包器, 每个包用Split标记结尾

func (*SplitPacketProcessor) Data

func (spp *SplitPacketProcessor) Data(data []byte) (n int)

func (*SplitPacketProcessor) Listen

func (spp *SplitPacketProcessor) Listen(onPacket func(p []byte))

Jump to

Keyboard shortcuts

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