Closed robodude666 closed 10 years ago
Hi @robodude666
the PushStream.js does not use the event type, but the server support it,respecting the RFC. you can use it with the default EventSource class like described here
Authors can separate events by using different event types. Here is a stream that has two event types, "add" and "remove":
event: add
data: 73857293
event: remove
data: 2153
event: add
data: 113411
The script to handle such a stream would look like this (where addHandler and removeHandler are functions that take one argument, the event):
var source = new EventSource('updates.cgi');
source.addEventListener('add', addHandler, false);
source.addEventListener('remove', removeHandler, false);
The default event type is "message".
Ah, okay. I don't recall reading that in the docs.
I have setup nginx and an example html file as described in the event_source example:
https://github.com/wandenberg/nginx-push-stream-module/blob/master/docs/examples/event_source.textile
If, for example, I try to use these headers:
the EventSource onmessage does not get triggered. I can manually navigate to /ev/channel?... and see the content being displayed, but the console nor the innerhtml are updating with the new events. If I remove the
Event-Type
from the header, it works fine, but with it the javascript doesn't get triggered.Example received when manually browsing to the /ev/channel?.. page:
Response headers for this request:
The data looks correct, and seems to comply with the SSE standards.
I'm using the Advanced Rest Client from the Google webstore, but I've also tried curl and python's requests, and all have the same results. I've tried the provided PushStream.js and the native EventSource(); both show the same thing.
The docs suggest that Event-Type should be usable. Is that the case, or is this a known issue?