From 58a853a241c52f35e4df9af386aa322f5807cbdd Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 25 Jul 2021 16:23:39 -0400 Subject: [PATCH] make server a bit more resiliant --- internal/coordinator/coordinator.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/internal/coordinator/coordinator.go b/internal/coordinator/coordinator.go index 58a8710..953ee98 100644 --- a/internal/coordinator/coordinator.go +++ b/internal/coordinator/coordinator.go @@ -57,12 +57,24 @@ func (c *Coordinator) Coordinate(cmd *SessionCommand) *SessionCommandResult { Result: SessionRespFound, } case SessionCmdJoin: + if c.Match == nil { + return &SessionCommandResult{ + ID: cmd.ID, + Result: SessionRespJoinError, + } + } resp := c.Match.Join(cmd.ID) return &SessionCommandResult{ ID: cmd.ID, Result: resp, } case SessionCmdLeave: + if c.Match == nil { + return &SessionCommandResult{ + ID: cmd.ID, + Result: SessionRespLeft, + } + } c.Match.Leave(cmd.ID) return &SessionCommandResult{ ID: cmd.ID,