MCPcopy
hub / github.com/davyxu/cellnet / DecodeMessageByType

Function DecodeMessageByType

codec/msgcodec.go:53–68  ·  view source on GitHub ↗
(data []byte, msg interface{})

Source from the content-addressed store, hash-verified

51}
52
53func DecodeMessageByType(data []byte, msg interface{}) (*cellnet.MessageMeta, error) {
54
55 meta := cellnet.MessageMetaByMsg(msg)
56 // 消息没有注册
57 if meta == nil {
58 return nil, cellnet.NewErrorContext("msg not exists", nil)
59 }
60
61 err := meta.Codec.Decode(data, msg)
62 if err != nil {
63 return meta, err
64 }
65
66 return meta, nil
67
68}
69
70// Codec.Encode内分配的资源,在必要时可以回收,例如内存池对象
71type CodecRecycler interface {

Callers

nothing calls this directly

Calls 3

MessageMetaByMsgFunction · 0.92
NewErrorContextFunction · 0.92
DecodeMethod · 0.65

Tested by

no test coverage detected