implement statuscode in packets
All checks were successful
Build and Publish / BuildAndDeploy (push) Successful in 2m2s

This commit is contained in:
matst80
2024-11-11 23:24:03 +01:00
parent 9c15251f67
commit 0b290a32bf
17 changed files with 295 additions and 226 deletions

View File

@@ -77,7 +77,8 @@ func (m *TCPClient) SendPacket(messageType uint32, data []byte) error {
err = binary.Write(m.Conn, binary.LittleEndian, Packet{
Version: CurrentPacketVersion,
MessageType: messageType,
DataLength: uint64(len(data)),
StatusCode: 0,
DataLength: uint32(len(data)),
})
if err != nil {
return m.HandleConnectionError(err)
@@ -94,7 +95,7 @@ func (m *TCPClient) SendPacket(messageType uint32, data []byte) error {
// return m.SendPacket(messageType, data)
// }
func (m *TCPClient) Call(messageType uint32, responseType uint32, data []byte) ([]byte, error) {
func (m *TCPClient) Call(messageType uint32, responseType uint32, data []byte) (*CallResult, error) {
packetChan := m.Expect(responseType)
err := m.SendPacket(messageType, data)
if err != nil {
@@ -103,7 +104,7 @@ func (m *TCPClient) Call(messageType uint32, responseType uint32, data []byte) (
select {
case ret := <-packetChan:
return ret, nil
return &ret, nil
case <-time.After(time.Second):
return nil, fmt.Errorf("timeout")
}