fix: gcConnOnError
This commit is contained in:
parent
8b617a8f9f
commit
77919b208f
@ -43,9 +43,10 @@ func WelcomeAgents(ws *websocket.Conn, welcome WSWelcome, t string) {
|
||||
}
|
||||
}
|
||||
|
||||
func gcConn(conn *websocket.Conn) (err error) {
|
||||
func gcConnOnError(ws *websocket.Conn) (err error) {
|
||||
for index, value := range LISTENERS {
|
||||
if value.ConnectionPS == conn || value.ConnectionRR == conn {
|
||||
if value.ConnectionPS == ws || value.ConnectionRR == ws {
|
||||
ws.Close()
|
||||
delete(LISTENERS, index)
|
||||
}
|
||||
}
|
||||
|
@ -50,12 +50,13 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error {
|
||||
|
||||
switch apievent.MsgType {
|
||||
case "bootstrap":
|
||||
log.Printf("bootstrap: %s\n", apievent.Hostname)
|
||||
for index, value := range LISTENERS {
|
||||
if index != apievent.Hostname {
|
||||
err = websocket.Message.Send(value.ConnectionPS, msg)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
gcConn(ws)
|
||||
gcConnOnError(ws)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -73,7 +74,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error {
|
||||
err = websocket.Message.Send(value.ConnectionPS, msg)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
gcConn(ws)
|
||||
gcConnOnError(ws)
|
||||
}
|
||||
}
|
||||
log.Printf("ws: Inserted event")
|
||||
@ -82,7 +83,7 @@ func HandleWSRR(c echo.Context, cfg *config.Config) error {
|
||||
err = websocket.Message.Send(value.ConnectionPS, msg)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
gcConn(ws)
|
||||
gcConnOnError(ws)
|
||||
}
|
||||
}
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user