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

Function MessageSize

meta.go:269–289  ·  view source on GitHub ↗
(msg interface{})

Source from the content-addressed store, hash-verified

267}
268
269func MessageSize(msg interface{}) int {
270
271 if msg == nil {
272 return 0
273 }
274
275 // 获取消息元信息
276 meta := MessageMetaByType(reflect.TypeOf(msg))
277 if meta == nil {
278 return 0
279 }
280
281 // 将消息编码为字节数组
282 raw, err := meta.Codec.Encode(msg, nil)
283
284 if err != nil {
285 return 0
286 }
287
288 return len(raw.([]byte))
289}
290
291func MessageToString(msg interface{}) string {
292

Callers 6

ResolveInboundEventFunction · 0.92
ResolveOutboundEventFunction · 0.92
WriteRecvLoggerFunction · 0.92
WriteSendLoggerFunction · 0.92
ResoleveInboundEventFunction · 0.92
ResolveOutboundEventFunction · 0.92

Calls 2

MessageMetaByTypeFunction · 0.85
EncodeMethod · 0.65

Tested by

no test coverage detected