W3C home > Mailing lists > Public > public-webapps@w3.org > July to September 2011

Re: [EventSource] Question on event type

From: Bryan Sullivan <blsaws@gmail.com>
Date: Thu, 8 Sep 2011 10:56:46 -0700
Message-ID: <CAA2gsfoRU2VTyGfd0Z7H5MyvaDUztrNuddad=g7_barrPKEwjw@mail.gmail.com>
To: Glenn Maynard <glenn@zewt.org>
Cc: public-webapps@w3.org
Thanks for the help.

So when you say "the name of the event", how in JavaScript do I access the
name of the event, e.g. to test it? Accessing  the data (event.data) works,
but how do access the name?

In your example, event.data is output but I don't see you accessing or using
the event name.


On Thu, Sep 8, 2011 at 10:46 AM, Glenn Maynard <glenn@zewt.org> wrote:

> 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:57:14 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:13:23 UTC