(l int)
| 63 | } |
| 64 | |
| 65 | func (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 | |
| 80 | func (t *TCPClient) ReadInt32() (int32, error) { |
| 81 | b, err := t.ReadBytes(4) |
no test coverage detected