Re: [EventSource] Is the field name "event" supported in current browsers?

Thanks for the explanation and examples. I've got it now. I agree it would
help if the spec was clearer and had some more examples. I will see what I
can offer.

Bryan

On Thu, Sep 8, 2011 at 12:41 PM, Glenn Maynard <glenn@zewt.org> wrote:

> On Thu, Sep 8, 2011 at 3:24 PM, Bryan Sullivan <blsaws@gmail.com> wrote:
>
>> I am trying to develop a test for eventsource, and am finding that when I
>> include an "event" field in an eventsource stream, the onmessage events are
>> never fired (if I don't send the "event" field, just "data" fields, the
>> events *are* fired). This occurs in FF, Safari, and Chrome (latest
>> end-user versions).
>>
>
> Please see the examples I linked earlier [1].  The default event type is
> "message", so if you don't include an "event" field, the "message" event is
> fired.  If you set "event: foo", you're changing the event to "foo", so the
> "foo" event is fired instead of the "message" event.
>
> (Note that you can't say "source.onfoo" like you can "source.onmessage";
> for custom message types you need to use addEventListener.)
>
> The EventSource spec is not really clear on this (there is no example that
>> shows an event field). If anyone is familiar with what should be supported,
>> please let me know if the following expectation is correct:
>>
>
> The EventSource spec assumes you're familiar with DOM Events via the
> DOMCORE and/or DOMEVENTS references.
> http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#events
>
>
>> The event stream below should result in a message event being fired, with
>> event.type set to "time" and event.data set to "Thu, 08 Sep 11 13:20:41
>> -0600":
>>
>> event: time
>> data: Thu, 08 Sep 11 13:20:41 -0600
>> (blank line)
>>
>
> This will cause a "time" event to be fired instead of a "message" event.
> The default is "message", set in step 3 of the steps you linked to earlier
> [2], and changed to "time" in step 4.
>
> Ian: Step 3 of [2] refers to the event type as "the event name", and step 4
> refers to it as "the type".  This is confusing, since it looks like it's
> referring to two different things.  The DOM specs consistently refer to it
> as "type", consistent with the Event interface.  I wish "type" could be
> changed to "name" everywhere, but then it'd be inconsistent with the
> interface (which obviously can't be changed).
>
> [1] https://zewt.org/~glenn/event-source.html<https://zewt.org/%7Eglenn/event-source2.html>,
> https://zewt.org/~glenn/event-source2.html
> [2] http://dev.w3.org/html5/eventsource/#dispatchMessage
>
> --
> Glenn Maynard
>
>

Received on Thursday, 8 September 2011 20:02:55 UTC