Class: Spikard::SseEventProducer
- Inherits:
-
Object
- Object
- Spikard::SseEventProducer
- Defined in:
- lib/spikard/sse.rb
Overview
Base class for SSE event producers.
Implement this class to generate Server-Sent Events.
Instance Method Summary collapse
-
#next_event ⇒ SseEvent?
Generate the next event.
-
#on_connect ⇒ void
Called when a client connects to the SSE endpoint.
-
#on_disconnect ⇒ void
Called when a client disconnects from the SSE endpoint.
Instance Method Details
#next_event ⇒ SseEvent?
Generate the next event.
This method is called repeatedly to produce the event stream.
89 90 91 |
# File 'lib/spikard/sse.rb', line 89 def next_event raise NotImplementedError, "#{self.class.name} must implement #next_event" end |
#on_connect ⇒ void
This method returns an undefined value.
Called when a client connects to the SSE endpoint.
Override this method to perform initialization when a client connects.
98 99 100 |
# File 'lib/spikard/sse.rb', line 98 def on_connect # Optional hook - default implementation does nothing end |
#on_disconnect ⇒ void
This method returns an undefined value.
Called when a client disconnects from the SSE endpoint.
Override this method to perform cleanup when a client disconnects.
107 108 109 |
# File 'lib/spikard/sse.rb', line 107 def on_disconnect # Optional hook - default implementation does nothing end |