[EventSource] Question on event type

Hi all,

Trying to implement a test for eventsource, it's unclear to me in the
sequence below, how item 4 is to be implemented and coded for by a
developer:

(extract from http://www.w3.org/TR/eventsource/)

When the user agent is required to *dispatch the event*, then the user agent
must act as follows:

   1. If the *data* buffer is an empty string, set the *data* buffer and the
   *event name* buffer to the empty string and abort these steps.
   2. If the *data* buffer's last character is a U+000A LINE FEED (LF)
   character, then remove the last character from the *data* buffer.
   3. Otherwise, create an event that uses the MessageEvent interface, with
   the event name message, which does not bubble, is not cancelable, and has
   no default action. The data attribute must be set to the value of the *
   data* buffer, the origin attribute must be set to the Unicode
   serialization of the origin of the event stream's URL, and the
   lastEventId attribute must be set to the last event ID string of the
   event source.
   4. If the *event name* buffer has a value other than the empty string,
   change the type of the newly created event to equal the value of the *event
   name* buffer.
   5. Set the *data* buffer and the *event name* buffer to the empty string.
   6. Queue a task to dispatch the newly created event at the EventSourceobject

(end extract)

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?

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.

Bryan

Received on Thursday, 8 September 2011 17:17:20 UTC