Aida with Realtime (WebSockets) support released

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Aida with Realtime (WebSockets) support released

Janko Mivšek
Dear Smalltalkers,

I think it can be safely claimed that Aida/Web is a first Smalltalk web
framework, even more, one of the first frameworks at all to integrate
HTML5 WebSockets for so called realtime web apps. Realtime in sense that
values on the page are updated immediately when value changes on the
server, without needing to manually reload a page.

You can see that in action from WebSocket-capable browsers (latest
Firefox and Chrome) if you open in two browsers the online Aida realtime
counter demo, click buttons on one and observe changes instantly in both
browsers:

        http://demo.aidaweb.si/demos?view=realtime

And how easy is using real-time in your code? See the simplified code of
above demo:

  WebDemoApp>>viewRealtime

    | e counterElement |

    self enableRealtime.

    counterElement := e add: self counterElement.

    (e addButtonText: ' Decrement ')
        noSubmit;
        onClickDo: [self observee decCounter].
    (e addButtonText: ' Increment ')
        noSubmit;
        onClickDo: [self observee incCounter].

    self observee
        onChangeDo: [counterElement update]
        on: counterElement app: self.

    self add: e.

  WebDemoApp>>counterElement

    | e |
    e := WebElement newSpan.
    e style: 'font-size: 40px'.
    e addText: self observee counter printString.
   ^e

To describe this code a bit: you first enable realtime for this view of
demo App. Element on the webpage to update in realtime must be created
in a separate method (#counterElement). After buttons for increment and
decrement we come to the main part - registering the block to execute on
every change of domain object. Calling simply #update to the counter
element is enough to be updated on all browsers which currently observe
that counter demo.

How this works? Behind the scenes a so called realtime channel is open
between browser and Aida server. This WebSocket based channel is
bidirectional and full-duplex, meaning that Aida can send back to the
browser a message at any time. In above case a command to update the
counter element is sent back to all browsers immediately after counter
is changed.

New Aida 6.5 Interim release is released for Squeak, Pharo and
VisualWorks and available from usual places. See http://www.aidaweb.si
for more.

Everyone is welcome to try it and come with suggestions how to use this
new feature, how to improve it, ....

Further read:

   http://www.aidaweb.si/websocket%20support
   http://www.swazoo.org/websocket

Best regards
Janko


--
Janko Mivšek
Aida/Web
Smalltalk Web Application Server
http://www.aidaweb.si
_______________________________________________
Aida mailing list
[hidden email]
http://lists.aidaweb.si/mailman/listinfo/aida
Loading...