From 812deb4bdc57c2da91d01aafd77292600be1f073 Mon Sep 17 00:00:00 2001 From: raul Date: Tue, 4 Jun 2024 16:09:07 +0200 Subject: [PATCH] Configure modular setup for different instructions --- main.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index aabb7c3..ec3de26 100644 --- a/main.go +++ b/main.go @@ -123,13 +123,21 @@ func awaitInstructions(conn net.Conn) error { if err != nil { return err } - if inst.IsHeartbeat == true && inst.Message == "PING" { - resp := Response{ - Message: "PONG", + + switch { + /////////////////////////////// + case inst.IsHeartbeat == true && inst.Message == "PING": + resp := Response{Message: "PONG"} + err := sendMessage(resp, conn) + if err != nil { + return err } - sendMessage(resp, conn) return nil + /////////////////////////////// + default: + sendMessage(Response{Message: "Unknown order!"}, conn) } + /////////////////////////////// return nil }