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