Tiny tweaks

This commit is contained in:
raul 2024-06-06 09:32:24 +02:00
parent f0c31dcd95
commit 4a0aafe237
1 changed files with 7 additions and 7 deletions

View File

@ -95,8 +95,8 @@ func sendCommand(ID int, command string) (Output string, err error) {
clientList[ID].Instruct(inst)
resp, err := ServerMessageReceiver(clientList[ID].Conn)
if err != nil || resp.Successful != true {
fmt.Println("Something went wrong")
return "", err
e := fmt.Errorf("%v\n", resp.Message)
return "", e
}
fmt.Println(resp.Message)
return resp.Message, nil
@ -119,7 +119,7 @@ func Heartbeat(ID int) {
return
}
time.Sleep(time.Second * 5)
time.Sleep(time.Second * 10)
}
}
@ -129,18 +129,18 @@ func returnClient(ID int) (Client, error) {
return v, nil
}
}
err := fmt.Errorf("Client not found")
err := fmt.Errorf("Client not found\n")
return Client{}, err
}
func ServerMessageReceiver(conn net.Conn) (Response, error) {
dec := gob.NewDecoder(conn)
c := new(Response)
err := dec.Decode(c)
c := Response{}
err := dec.Decode(&c)
if err != nil {
return Response{}, err
}
return *c, nil
return c, nil
}
func getClient(conn net.Conn) (int, error) {