Skip to content

Commit

Permalink
Adding closes
Browse files Browse the repository at this point in the history
  • Loading branch information
COMTOP1 committed Dec 25, 2023
1 parent 747d039 commit 828337d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/views/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (v *Views) Websocket(c echo.Context) error {
err = json.Unmarshal(msg, &responseTransporter)
if err != nil {
log.Printf("failed to unmarshal response: %+v", err)
_ = ws.Close()
return nil
}

Expand Down Expand Up @@ -115,6 +116,7 @@ func (v *Views) Websocket(c echo.Context) error {
err = ws.WriteMessage(websocket.TextMessage, []byte(specialWSMessage.Ping))
if err != nil {
log.Printf("failed to write ping for %s: %+v", responseTransporter.Server, err)
close(internalChannel)
close(clientChannel)
v.cache.Delete(responseTransporter.Server.String())
v.cache.Delete(responseTransporter.Server.String() + internalChannelNameAppend)
Expand All @@ -124,6 +126,7 @@ func (v *Views) Websocket(c echo.Context) error {
msgType, msg, err = ws.ReadMessage()
if err != nil || msgType != websocket.TextMessage || string(msg) != specialWSMessage.Pong.String() {
log.Printf("failed to read pong for %s: %+v", responseTransporter.Server, err)
close(internalChannel)
close(clientChannel)
v.cache.Delete(responseTransporter.Server.String())
v.cache.Delete(responseTransporter.Server.String() + internalChannelNameAppend)
Expand Down

0 comments on commit 828337d

Please sign in to comment.