File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -275,10 +275,11 @@ func (c *wsConn) handleChanOut(ch reflect.Value, req interface{}) error {
275275
276276// handleCtxAsync handles context lifetimes for client
277277// TODO: this should be aware of events going through chanHandlers, and quit
278- // when the related channel is closed.
279- // This should also probably be a single goroutine,
280- // Note that not doing this should be fine for now as long as we are using
281- // contexts correctly (cancelling when async functions are no longer is use)
278+ //
279+ // when the related channel is closed.
280+ // This should also probably be a single goroutine,
281+ // Note that not doing this should be fine for now as long as we are using
282+ // contexts correctly (cancelling when async functions are no longer is use)
282283func (c * wsConn ) handleCtxAsync (actx context.Context , id interface {}) {
283284 <- actx .Done ()
284285
@@ -486,6 +487,14 @@ func (c *wsConn) setupPings() func() {
486487 }
487488 return nil
488489 })
490+ c .conn .SetPingHandler (func (appData string ) error {
491+ // treat pings as pongs - this lets us register server activity even if it's too busg to respond to our pings
492+ select {
493+ case c .pongs <- struct {}{}:
494+ default :
495+ }
496+ return nil
497+ })
489498
490499 stop := make (chan struct {})
491500
You can’t perform that action at this time.
0 commit comments