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

Method ReadBytes

client/internal/network/conn.go:65–78  ·  view source on GitHub ↗
(l int)

Source from the content-addressed store, hash-verified

63}
64
65func (t *TCPClient) ReadBytes(l int) ([]byte, error) {
66 buf := make([]byte, l)
67 if conn := t.getConn(); conn != nil {
68 _, err := io.ReadFull(conn, buf)
69 if err != nil {
70 // time.Sleep(time.Millisecond * 100) // 服务器会发送offline包后立即断开连接, 此时还没解析, 可能还是得加锁
71 t.unexpectedClose(err)
72 return nil, ErrConnectionClosed
73 }
74 return buf, nil
75 }
76
77 return nil, ErrConnectionClosed
78}
79
80func (t *TCPClient) ReadInt32() (int32, error) {
81 b, err := t.ReadBytes(4)

Callers 3

ReadInt32Method · 0.95
netLoopMethod · 0.45
readResponseFunction · 0.45

Calls 2

getConnMethod · 0.95
unexpectedCloseMethod · 0.95

Tested by

no test coverage detected