Documentation ¶
Index ¶
- Constants
- Variables
- type CodecHelper
- func (d *CodecHelper) Decode(data []byte) (*packet.Packet, error)
- func (d *CodecHelper) Encode(in interface{}, name ...string) (*packet.Packet, error)
- func (d *CodecHelper) GetTypes() (map[string]uint8, string)
- func (d *CodecHelper) RegisterDecode(decodeKey uint8, c PacketDecode) error
- func (d *CodecHelper) RegisterEncode(v uint8, e PacketEncode)
- type Dispatch
- type JSONDecode
- type JSONEncode
- type PacketDecode
- type PacketEncode
- type Ping
- type Pong
- type ProtoDecode
- type ProtoEncode
Constants ¶
Variables ¶
View Source
var ( ErrActionNotFound = errors.New("action not found") ErrMethodNotFound = errors.New("method not found") ErrMessageDecode = errors.New("message decode error") ErrRegisterCodecType = errors.New("register codec type error") ErrRegisterCodecTypeExist = errors.New("register codec type exist") ErrCodecType = errors.New("codec type error") ErrNotValidJSONType = errors.New("not valid json type") ErrActionNotExist = errors.New("action not exist") ErrInvalidProtoMessage = errors.New("invalid proto message") )
View Source
var File_test_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type CodecHelper ¶
func NewCodecHelper ¶
func NewCodecHelper(config *config.Config, dispatcher Dispatch) *CodecHelper
func (*CodecHelper) Encode ¶
func (d *CodecHelper) Encode(in interface{}, name ...string) (*packet.Packet, error)
func (*CodecHelper) RegisterDecode ¶
func (d *CodecHelper) RegisterDecode(decodeKey uint8, c PacketDecode) error
func (*CodecHelper) RegisterEncode ¶
func (d *CodecHelper) RegisterEncode(v uint8, e PacketEncode)
type Dispatch ¶
type Dispatch interface { GetAction(in interface{}) (uint32, error) //直接通过反射获取对象的ActionKey GetActionByName(string) (uint32, error) //通过名称获取对象的ActionKey GetObj(uint32) (interface{}, bool) }
Dispatch 用于获取对象类型和ActionKey
type JSONDecode ¶
type JSONDecode struct{}
func (*JSONDecode) Decode ¶
func (c *JSONDecode) Decode(data []byte, in interface{}) error
func (*JSONDecode) String ¶
func (c *JSONDecode) String(in interface{}) string
type JSONEncode ¶
type JSONEncode struct{}
func (*JSONEncode) Encode ¶
func (c *JSONEncode) Encode(in interface{}) ([]byte, error)
func (*JSONEncode) String ¶
func (c *JSONEncode) String(in interface{}) string
type PacketDecode ¶
type PacketEncode ¶
type Ping ¶
type Ping struct { Time string `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"` // contains filtered or unexported fields }
@gogs:Request
func (*Ping) Descriptor
deprecated
func (*Ping) ProtoMessage ¶
func (*Ping) ProtoMessage()
func (*Ping) ProtoReflect ¶
func (x *Ping) ProtoReflect() protoreflect.Message
type Pong ¶
type Pong struct { Time string `protobuf:"bytes,1,opt,name=time,proto3" json:"time,omitempty"` // contains filtered or unexported fields }
func (*Pong) Descriptor
deprecated
func (*Pong) ProtoMessage ¶
func (*Pong) ProtoMessage()
func (*Pong) ProtoReflect ¶
func (x *Pong) ProtoReflect() protoreflect.Message
type ProtoDecode ¶
type ProtoDecode struct{}
func (*ProtoDecode) Decode ¶
func (c *ProtoDecode) Decode(data []byte, in interface{}) error
func (*ProtoDecode) String ¶
func (c *ProtoDecode) String(in interface{}) string
type ProtoEncode ¶
type ProtoEncode struct{}
func (*ProtoEncode) Encode ¶
func (c *ProtoEncode) Encode(in interface{}) ([]byte, error)
func (*ProtoEncode) String ¶
func (c *ProtoEncode) String(in interface{}) string
Click to show internal directories.
Click to hide internal directories.