From cdf482835f898866163dd305ac77b0a4b4fbf834 Mon Sep 17 00:00:00 2001 From: amirhnajafiz Date: Thu, 11 Aug 2022 20:01:08 +0430 Subject: [PATCH] feat: topic check before executing handle --- internal/client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/client.go b/internal/client.go index 65b33a3..ea2b731 100644 --- a/internal/client.go +++ b/internal/client.go @@ -85,7 +85,9 @@ func (c *client) listen() { // handle will execute the topic handler method. func (c *client) handle(m message) { - c.topics[m.Topic](m.Data) + if handler, ok := c.topics[m.Topic]; ok { + handler(m.Data) + } } // close will terminate everything.