protocol

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateChannel = errors.New("duplicate channel")
	ErrChannelNotFound  = errors.New("channel not found")
)
View Source
var (
	ErrProtoIDNotFound = errors.New("proto id not found")
)

Functions

func Error

func Error(r Response) error

Types

type FutuDecoder

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

func NewDecoder

func NewDecoder(reg *Registry) *FutuDecoder

func (*FutuDecoder) ReadFrom

func (de *FutuDecoder) ReadFrom(c net.Conn) (tcp.Handler, error)

type FutuEncoder

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

func NewEncoder

func NewEncoder(proto uint32, serial uint32, msg proto.Message) *FutuEncoder

func (*FutuEncoder) WriteTo

func (en *FutuEncoder) WriteTo(c net.Conn) error

type PBChan

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

用于接收到数据后,发送协议数据到接收goroutine

func NewPBChan

func NewPBChan(i interface{}) (*PBChan, error)

func (*PBChan) Close

func (ch *PBChan) Close()

func (*PBChan) Send

func (ch *PBChan) Send(b []byte) error

type Registry

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

Registry 接收数据处理器注册表

func NewRegistry

func NewRegistry() *Registry

NewRegistry 生成新的Registry

func (*Registry) AddGetChan

func (reg *Registry) AddGetChan(proto uint32, serial uint32, ch RespChan) error

AddGetChan 添加get方法的接收通道

func (*Registry) AddUpdateChan

func (reg *Registry) AddUpdateChan(proto uint32, ch RespChan) error

AddUpdateChan 添加update方法的接收通道

func (*Registry) Close

func (reg *Registry) Close()

Close 关闭Registry的worker

func (*Registry) RemoveChan

func (reg *Registry) RemoveChan(proto uint32, serial uint32) error

type RespChan

type RespChan interface {
	Send(b []byte) error
	Close()
}

type Response

type Response interface {
	GetRetType() int32
	GetRetMsg() string
}

Jump to

Keyboard shortcuts

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