Re: [EventSource] Question on event type

On Thu, Sep 8, 2011 at 1:16 PM, Bryan Sullivan <blsaws@gmail.com> wrote:
> The event type for the MessageEvent is "message" (in all browsers I have
tested, and there is no other "type" attribute defined for MessageEvent. So
if I send from my server a line "event: foo\n", I would expect from reading
above that the event attribute "type" is set to "foo". What am I missing?

Note that "event type" with DOM Events terms really means the name of the
event.  Changing it doesn't change the type in the sense of giving it a
different interface; it's just a different label that you can listen for
with addEventListener.

This allows listening to different remote message types with different event
handlers.  See https://zewt.org/~glenn/event-source.html for an example.

It would be good to have an example of this in the spec.

> FYI, my test is at http://test.bkaj.net/webapi/server-sent-events/. I have
yet to figure out how to get PHP (or the underlying Apache server) to not
buffer output, so I send enough data to fill the buffer - a bad kludge but
it makes the test work (I think). Any help there is also appreciated.

flush() (http://php.net/manual/en/function.flush.php) does this at the PHP
level; whether it works at the HTTP server level varies.

--
Glenn Maynard

Received on Thursday, 8 September 2011 17:47:01 UTC