Happy !

MasashiUmezawa / SeSSE

Project infos

License MIT
Tags sse, seaside, server sent events, eventsource
Creation date 2015-06-20
Website

Monticello registration

About SeSSE

Seaside with Server-Sent Events (SeSSE)

SeSSE is a small library for supporting Server-Sent Events (SSE) on Seaside.

How to use

Please see SeSlider in SeSSE-Examples package. Actually its usage is very similar to Seaside Comet. (SSE is a sort of successor of Comet, so it is natural).

Followings are some snippets from SeSlider.

Broadcasting events

self caster castEvent: #sliderChanged data: value.

Handling events

html document
    addLoadScript: (html eventSource caster: self class caster;
            onOpen: 'alert("SSE " + ev.type);';
            onError: 'console.warn(ev);';
            addEventListener: #sliderChanged do: '$("#slider").slider("value",ev.data)';
            addEventListener: #sliderChanged do: 'console.info(ev.data)';
            addEventListener: #sliderChanged do: [:ev | ev inspect]
    )

Installation

Gofer new
  url: 'http://smalltalkhub.com/mc/MasashiUmezawa/SeSSE/main';
  package: 'ConfigurationOfSeSSE';
  load.
(Smalltalk at: #ConfigurationOfSeSSE) load

Settings

In order to activate SSE, you need to use streaming-enabled server adaptor on Seaside. It is the same as Seaside Comet.

WAServerManager default stopAll; initialize.
ZnZincStreamingServerAdaptor startOn: 9000.

Polyfill eventsource.js

For old browsers that do not support SSE, SeSSE uses the eventsource.js polyfill library.

It is embedded in SeJsLibrary. Since it is just a WAFileLibrary, you can use other polyfill JS by replacing SeJsLibrary.

Acknowledgements

Thanks to the Seaside Comet authors for the inspiration. I borrowed lots of design.