pio

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: GPL-3.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	NoAsk   byte = 0x00
	SendAsk byte = 0x01
	RecvAsk byte = 0x02
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	OnPktNotFound func(id uint32, body encoding.Reader)
	OnParseError  func(pkt PacketBase, err error)
	// contains filtered or unexported fields
}

func NewConn

func NewConn(r io.Reader, w io.Writer) (c *Conn)

func NewConnContext

func NewConnContext(ctx context.Context, r io.Reader, w io.Writer) (c *Conn)

func OsPipe

func OsPipe() (c *Conn, br, bw *os.File, err error)

func Pipe

func Pipe() (a, b *Conn)

func (*Conn) AddPacket

func (c *Conn) AddPacket(newer PacketNewer)

func (*Conn) AsStream added in v0.2.0

func (c *Conn) AsStream() (rw io.ReadWriteCloser, err error)

func (*Conn) Ask

func (c *Conn) Ask(p PacketBase) (res PacketBase, err error)

func (*Conn) AskWith added in v0.1.2

func (c *Conn) AskWith(ctx context.Context, p PacketBase) (res PacketBase, err error)

func (*Conn) Close

func (c *Conn) Close() (err error)

func (*Conn) Context added in v0.1.2

func (c *Conn) Context() context.Context

func (*Conn) NewPacket

func (c *Conn) NewPacket(pid uint32) PacketBase

func (*Conn) Ping

func (c *Conn) Ping() (ping time.Duration, err error)

func (*Conn) PingWith added in v0.1.2

func (c *Conn) PingWith(ctx context.Context) (ping time.Duration, err error)

func (*Conn) PopPacket added in v0.2.1

func (c *Conn) PopPacket(pid uint32) (ok bool)

func (*Conn) Send

func (c *Conn) Send(p PacketBase) (err error)

func (*Conn) Serve

func (c *Conn) Serve() (err error)

func (*Conn) ServeDone added in v0.2.0

func (c *Conn) ServeDone() <-chan struct{}

func (*Conn) StreamedDone added in v0.2.0

func (c *Conn) StreamedDone() <-chan struct{}

type ConnState added in v0.2.0

type ConnState int
const (
	ConnInited ConnState = iota
	ConnServing
	ConnPreStream
	ConnStreamed
)

type EmptyPkt added in v0.2.0

type EmptyPkt struct {
	Id uint32
}

func (EmptyPkt) ParseFrom added in v0.2.0

func (EmptyPkt) ParseFrom(encoding.Reader) error

func (EmptyPkt) PktId added in v0.2.0

func (pkt EmptyPkt) PktId() uint32

func (EmptyPkt) WriteTo added in v0.2.0

func (EmptyPkt) WriteTo(encoding.Writer) error

type EmptyPktAsk added in v0.2.0

type EmptyPktAsk struct {
	EmptyPkt
	OnAsk func() (PacketBase, error)
}

func (EmptyPktAsk) Ask added in v0.2.0

func (pkt EmptyPktAsk) Ask() (PacketBase, error)

type EmptyPktTrigger added in v0.2.0

type EmptyPktTrigger struct {
	EmptyPkt
	OnTrigger func() error
}

func (EmptyPktTrigger) Trigger added in v0.2.0

func (pkt EmptyPktTrigger) Trigger() error

type Ok added in v0.2.2

type Ok struct{}

func (Ok) ParseFrom added in v0.2.2

func (Ok) ParseFrom(encoding.Reader) error

func (Ok) PktId added in v0.2.2

func (Ok) PktId() uint32

func (Ok) WriteTo added in v0.2.2

func (Ok) WriteTo(encoding.Writer) error

type Packet

type Packet interface {
	PacketBase
	Trigger() error
}

func NewPktTrigger added in v0.2.0

func NewPktTrigger(id uint32, ontrigger func() error) Packet

type PacketAsk

type PacketAsk interface {
	PacketBase
	Ask() (PacketBase, error)
}

func NewPktAsk added in v0.2.0

func NewPktAsk(id uint32, onask func() (PacketBase, error)) PacketAsk

type PacketBase

type PacketBase interface {
	PktId() uint32
	ParseFrom(encoding.Reader) error
	WriteTo(encoding.Writer) error
}
var OkPkt PacketBase = Ok{}

func NewPkt added in v0.2.0

func NewPkt(id uint32) PacketBase

type PacketNewer

type PacketNewer func() PacketBase

type Ping

type Ping struct {
	Payload uint64
}

func (*Ping) Ask

func (p *Ping) Ask() (res PacketBase, err error)

func (*Ping) ParseFrom

func (p *Ping) ParseFrom(r encoding.Reader) (err error)

func (*Ping) PktId

func (*Ping) PktId() uint32

func (*Ping) WriteTo

func (p *Ping) WriteTo(w encoding.Writer) (err error)

type Pong

type Pong struct {
	Payload uint64
}

func (*Pong) ParseFrom

func (p *Pong) ParseFrom(r encoding.Reader) (err error)

func (*Pong) PktId

func (*Pong) PktId() uint32

func (*Pong) WriteTo

func (p *Pong) WriteTo(w encoding.Writer) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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