protocol

package
v0.0.0-...-e1eba21 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

protocol 为消息添加header信息,从tcp连接中解析数据,转换protobuf数据和[]byte格式

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(r Response) error

Error将Response转换为error类型

Types

type FutuProtocol

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

func Connect

func Connect(address string, api map[uint32]Worker) (*FutuProtocol, error)

func (*FutuProtocol) Close

func (ft *FutuProtocol) Close() error

func (*FutuProtocol) RegisterGet

func (ft *FutuProtocol) RegisterGet(proto uint32, req proto.Message, out *ProtobufChan) error

func (*FutuProtocol) RegisterUpdate

func (ft *FutuProtocol) RegisterUpdate(proto uint32, out *ProtobufChan) error

func (*FutuProtocol) SerialNo

func (ft *FutuProtocol) SerialNo() uint32

type ProtobufChan

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

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

func NewProtobufChan

func NewProtobufChan(i any) *ProtobufChan

从chan *T类型转换为ProtobufChan类型,T为struct,*T实现proto.Message

type Response

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

Response是protobuf接口定义的返回信息获取方法

type Worker

type Worker interface {
	// contains filtered or unexported methods
}

func NewGetter

func NewGetter() Worker

func NewUpdater

func NewUpdater() Worker

Jump to

Keyboard shortcuts

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