added conn close on ping call
This commit is contained in:
parent
583742eef6
commit
5858b1398f
@ -33,6 +33,7 @@ func HandleWSPS(c *echo.Context, cfg *config.Config) (err error) {
|
||||
err = websocket.Message.Receive(ws, "OK")
|
||||
if err != nil {
|
||||
log.Printf("disconnect: %s (from pubsub channel)\n", welcome.Hostname)
|
||||
ws.Close()
|
||||
}
|
||||
|
||||
for {
|
||||
|
@ -57,6 +57,7 @@ func HandleWSRR(c *echo.Context, cfg *config.Config) error {
|
||||
err = websocket.Message.Send(value.(*connectionInfo).ConnectionPS, msg)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
ws.Close()
|
||||
gcConnOnError(ws)
|
||||
}
|
||||
}
|
||||
@ -77,6 +78,7 @@ func HandleWSRR(c *echo.Context, cfg *config.Config) error {
|
||||
err = websocket.Message.Send(value.(*connectionInfo).ConnectionPS, msg)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
ws.Close()
|
||||
gcConnOnError(ws)
|
||||
}
|
||||
}
|
||||
@ -89,19 +91,31 @@ func HandleWSRR(c *echo.Context, cfg *config.Config) error {
|
||||
err = websocket.Message.Send(value.(*connectionInfo).ConnectionPS, msg)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
ws.Close()
|
||||
gcConnOnError(ws)
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
case "ping":
|
||||
log.Printf("ping: %s\n", apievent.Hostname)
|
||||
listeners.Range(func(index, value interface{}) bool {
|
||||
if index == apievent.Hostname && value.(*connectionInfo).ConnectionPS != nil {
|
||||
err = websocket.Message.Send(value.(*connectionInfo).ConnectionPS, msg)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
ws.Close()
|
||||
gcConnOnError(ws)
|
||||
}
|
||||
}
|
||||
return true
|
||||
})
|
||||
default:
|
||||
}
|
||||
|
||||
err = websocket.Message.Send(ws, "OK")
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
gcConnOnError(ws)
|
||||
}
|
||||
}
|
||||
}).ServeHTTP((*c).Response(), (*c).Request())
|
||||
|
Loading…
Reference in New Issue
Block a user