MCPcopy Create free account
hub / github.com/LagrangeDev/LagrangeGo / MarshalJSON

Method MarshalJSON

client/statistics.go:27–48  ·  view source on GitHub ↗

MarshalJSON encodes the wrapped statistics into JSON.

()

Source from the content-addressed store, hash-verified

25
26// MarshalJSON encodes the wrapped statistics into JSON.
27func (m *Statistics) MarshalJSON() ([]byte, error) {
28 var w bytes.Buffer
29 w.Grow(256)
30 w.WriteString(`{"packet_received":`)
31 w.WriteString(strconv.FormatUint(m.PacketReceived.Load(), 10))
32 w.WriteString(`,"packet_sent":`)
33 w.WriteString(strconv.FormatUint(m.PacketSent.Load(), 10))
34 w.WriteString(`,"packet_lost":`)
35 w.WriteString(strconv.FormatUint(m.PacketLost.Load(), 10))
36 w.WriteString(`,"message_received":`)
37 w.WriteString(strconv.FormatUint(m.MessageReceived.Load(), 10))
38 w.WriteString(`,"message_sent":`)
39 w.WriteString(strconv.FormatUint(m.MessageSent.Load(), 10))
40 w.WriteString(`,"disconnect_times":`)
41 w.WriteString(strconv.FormatUint(uint64(m.DisconnectTimes.Load()), 10))
42 w.WriteString(`,"lost_times":`)
43 w.WriteString(strconv.FormatUint(uint64(m.LostTimes.Load()), 10))
44 w.WriteString(`,"last_message_time":`)
45 w.WriteString(strconv.FormatInt(m.LastMessageTime.Load(), 10))
46 w.WriteByte('}')
47 return w.Bytes(), nil
48}

Callers

nothing calls this directly

Calls 1

BytesMethod · 0.80

Tested by

no test coverage detected