From 09b3cc8921dd82bfb41d622d0f490005465bccdb Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Wed, 2 May 2018 23:47:00 +0200 Subject: [PATCH] add close case (payload size = 0) --- ws/client/public.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ws/client/public.go b/ws/client/public.go index bb21003..0505667 100644 --- a/ws/client/public.go +++ b/ws/client/public.go @@ -118,6 +118,8 @@ func (c *T) reader(unregister chan <-*T){ // fmt.Printf(" [reader] sent PONG back\n") continue + } else if msg.Size == 0 && ( msg.Type == message.TEXT || msg.Type == message.BINARY ) { + break } /* (3) Dispatch to receiver */ @@ -127,6 +129,7 @@ func (c *T) reader(unregister chan <-*T){ // return closing callback c.Ch.Close <- func(){ + unregister <- c }