How to learn about Comet in Seaside?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to learn about Comet in Seaside?

Nick Smith
Hi, I'm new to Smalltalk and Seaside and must say I'm enjoying learning both immensely.  I've worked my through 'Squeak by Example' and 'An Introduction to Seaside' and would like now like to implement Comet style 'server push' in a web app.

Problem is I can't find any documentation anywhere, so I've tried to figure it out by browsing the Comet classes and method comments (in Damien Cassou's latest web imagine... the tools in here are fantastic) but I'm probably not experienced enough to understand just by reading code.  

Any pointers to notes, blog posts or docs. would be really appreciated.  Thanks.

Nick Smith
Reply | Threaded
Open this post in threaded view
|

Re: How to learn about Comet in Seaside?

cedreek
Hi Nick and welcome :)

2008/6/14 Nick Smith <[hidden email]>:
>
> Hi, I'm new to Smalltalk and Seaside and must say I'm enjoying learning both
> immensely.  I've worked my through 'Squeak by Example' and 'An Introduction
> to Seaside' and would like now like to implement Comet style 'server push'
> in a web app.

You should have a closer look at CTChat, and CTCounter and CTSession.

To run the examples (I don't know if you did), you have to run a web
listener so that the connection is always open to push information. So
instead of using one of the WAKom, you run WAListener startOn: 8888.
Then you browse to localhost:8888/seaside/browse and you should see
comet exemples.

>
> Problem is I can't find any documentation anywhere, so I've tried to figure
> it out by browsing the Comet classes and method comments (in Damien Cassou's
> latest web imagine... the tools in here are fantastic) but I'm probably not
> experienced enough to understand just by reading code.
>
> Any pointers to notes, blog posts or docs. would be really appreciated.

Comet is not really tested and used I guess. I cannot help here too
much. Just look closer at CTChat and CTCounter especially class side.
You need to have a class instance variable name pusher that is
initialized (lazily) with a CTPusher. Then in you render method, you
need to render at the end the script that does the magic (see in both
renderContentOn:).

        html script: (html comet
                pusher: self pusher;
                connect)

I think that's nearly all. Don't forget to use a CTSession. Initialize
properly the app (see examples). Here is the one for the chat:

initialize
        | application |
        application := self registerAsApplication: 'comet/chat'.
        application preferenceAt: #sessionClass put: CTChatSession.
        application addLibrary: SULibrary; addLibrary: CTLibrary

Last point, to udpate in other browsers, you need a to use self pucher
javascript: [:aScript |], like:

CTChat>>push: aString with: aBlock
        self pusher javascript: [ :script |
                script element id: 'messages'; insertTop: [ :html |
                        self renderMessage: aBlock class: aString on: html ] ]

CTCounter>>update: anAspect
        "Update the number in all connected web browser. Only the first 4
lines are really needed, the rest adds some eye-candy and can simply
be removed if not needed."

        self pusher javascript: [ :script |
                script element
                        id: 'count';
                        update: self model count.
...
hth

Cédrick

ps: to Lukas and others, couldn't we have a class CTComponent to be
the common superclass of Comet apps. It could have pusher class inst
var and its accessor. Also, we could maybe get rid of having to write
:
html script: (html comet
                pusher: self pusher;
                connect)

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: How to learn about Comet in Seaside?

Nick Smith
Thanks Cedrick, this is just what I need to get started.

>>Comet is not really tested and used I guess.  

That really surprised me.  This seems such a big leap forward from an user experience perspective that I thought others would have implemented this already somewhere.  Looks like I'm going to have to roll my sleeves up and get dirty.  :)

I am keen to eventually to use Seaside on Gemstone (for scaling reasons).  Can anyone tell me if Comet is (or could be) implemented on their platform.  Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: How to learn about Comet in Seaside?

Philippe Marschall
2008/6/15, Nick Smith <[hidden email]>:

>  >>Comet is not really tested and used I guess.
>
> That really surprised me.

Comet is a hack into the HTTP protocol. To make it do something is was
not designed to do.

>  I am keen to eventually to use Seaside on Gemstone (for scaling reasons).
>  Can anyone tell me if Comet is (or could be) implemented on their platform.
>  Thanks.

It's best to ask on their mailing list:
[hidden email]

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside