kenichi / angelo

Sinatra-like DSL for Reel that supports WebSockets and SSE
Other
302 stars 23 forks source link

Adding SSE Support #2

Closed tpitale closed 10 years ago

tpitale commented 10 years ago

This is sort of a feature request. But, it's one I'm hoping to work on if you're interested in having this as a feature.

There's not too much work to be done on it, and I'll probably just adapt the work I did for this gist example: https://gist.github.com/tpitale/4004298

tpitale commented 10 years ago

@kenichi any interest in this? One way or the other?

kenichi commented 10 years ago

@tpitale sorry, been on vacation - looking...

tpitale commented 10 years ago

No worries, one never knows :smile:

kenichi commented 10 years ago

@tpitale hey, i forked and tried to get your gist to work:

https://gist.github.com/kenichi/de652d1ef7705716c126

but i can't get anything but bizarre encoding errors from chrome. am i doing something obviously wrong?

tpitale commented 10 years ago

Oh, the gist is a proof of the SSE concept. I haven't checked to see if it works standalone in some time.

If it helps, I'll try to get it working tomorrow.

kenichi commented 10 years ago

@tpitale i think the feature is a good one, and should be added. websockets are great, but SSE/EventSource is a better choice for many cases. do you have ideas for implementation in angelo?

i tend towards sinatra compatibility, but am open to deviate. here's a sinatra example: https://gist.github.com/rkh/1476463

tpitale commented 10 years ago

Yeah, I'll try to create something soon and send a PR. Thanks @kenichi!

kenichi commented 10 years ago

@tpitale i played with the gist a bit more, and got it working:

https://gist.github.com/kenichi/de652d1ef7705716c126

kenichi commented 10 years ago

@tpitale what do you think of this addition to the DSL?

https://github.com/kenichi/angelo/compare/sse

tpitale commented 10 years ago

That looks great @kenichi!

I'd be happy to try to play with it in a pet project tonight or tomorrow :-)

kenichi commented 10 years ago

@tpitale it seems like

var es = new EventSource('/sse');

always performs a GET request, so i'm thinking of moving it to the top-level like get, websocket, etc.

tpitale commented 10 years ago

I was going to ask about that. I think eventsource should basically have the similar top level api as get/websocket.

kenichi commented 10 years ago

cool, me too. i'm gonna try to make that happen over the weekend... we'll see how far i get :smiley_cat:

tpitale commented 10 years ago

Thanks @kenichi!

kenichi commented 10 years ago

@tpitale ok, i added quite a bit - see the readme additions on the branch at:

https://github.com/kenichi/angelo/tree/sse#sse---server-sent-events