runOnCloseHandlers runs all registered onClose handlers exactly once
()
| 332 | |
| 333 | // runOnCloseHandlers runs all registered onClose handlers exactly once |
| 334 | func (h *SSEHandlerCh) runOnCloseHandlers() { |
| 335 | h.lock.Lock() |
| 336 | if h.handlersRun { |
| 337 | h.lock.Unlock() |
| 338 | return |
| 339 | } |
| 340 | h.handlersRun = true |
| 341 | h.lock.Unlock() |
| 342 | |
| 343 | handlers := h.onCloseHandlers.GetList() |
| 344 | for _, fn := range handlers { |
| 345 | fn() |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | // Close closes the write channel, sends [DONE], and cleans up resources |
| 350 | func (h *SSEHandlerCh) Close() { |