class EventAction < Cramp::Action
self.transport = :sse
periodic_timer :send_named_event, :every => 5
def send_named_event
render "This event has a name", :event => "special"
end
end
The MessageEvent.type (received by the client) will be "special" rather than the default, which is just "message".
var source = new EventSource('/events');
source.addEventListener('special', function(e) {
console.log(e);
}, false);
Hi Pratik,
Just a quick patch that allows specification of an event name as an option to 'render' when using the :sse transport.
The MessageEvent.type (received by the client) will be "special" rather than the default, which is just "message".
Cheers, Luke