Check out the Red programming language from the same author

OS News is announcing Cheyenne new Web Socket support!

Nenad Rakocevic - Softinnov
4-Jan-2010 13:04:55 GMT

Article #20
Main page || Index || 2 Comments

You may have heard about Web Sockets. This extension of the HTTP protocol provides a mean for having long-lasting connections between client browsers and web servers in a clean and efficient way. 

Cheyenne jumped a few days ago in the new real-time web bandwagon by, not only supporting the new protocol, but also providing a new simple framework for those new kind of web applications. This new framework integrates nicely with the existing RSP engine benefiting from its multitasking abilities.

OS News published a nice article yesterday, written by Kaj de Vos from the Syllable OS team, announcing that Cheyenne supports now web sockets. Thanks to Kaj for pushing it up.

You can checkout this new version from the SVN repository (see Download page for info on how to checkout).

Chrome 4 is currently required to use Web Sockets. Hopefully, more browser will support it soon as part of the HTML5 feature set.

A fully commented simple "echo" application example is provided, full documentation will come in a few days. Also, a simple demo real-time chat application is available both online and in SVN for testing.

Here's the full server-side source code of the Chat demo application :

install-socket-app [
    name: 'chat

    ;-- stores [port! string!] pairs
    users:   make block! 10
    history: make block! 50

    ;-- send same data to all connected users
    broadcast: func [msg][
        foreach port clients [send port msg]

    on-connect: func [client][
        ;-- send messages' history to new user
        foreach entry history [send client entry]

        ;-- send connected users list
        foreach [port user] users [send client user]

    on-message: func [client data][
        ;-- escape all html tags for security concerns
        data: copy data
        replace/all data "<" "&lt;"
        replace/all data ">" "&gt;"

        switch data/1 [
            #"m" [
                ;-- insert [hh:mm:ss] time prefix
                insert next data join remold [now/time] " "
                append history data

                ;-- keep only 50 messages in history
                if 50 <= length? history [remove history]
            #"u" [
                if not find users data [
                    ;-- keep users list updated
                    repend users [client data]
        ;-- broadcast messages to all users
        broadcast data

    on-disconnect: func [client /local pos user][
        pos: find users client
        user: pos/2
        remove/part pos 2

        ;-- send user quit message to everyone
        broadcast head change user #"r"
Hope you'll enjoy this new toy. ;-)


16-Mar-2010 20:38:36
Bonjour, en dev j'utilise Windows et en prod Debian. Sous Windows pas de problème mais sous linux cela ne fonctionne pas. J'utilise la source pour pouvoir avoir la dernière version. Je pense qu'il doit y avoir une modification à faire mais cela fait trois jours que je décortique les fichiers sans arriver à savoir quoi faire. Donc si cela n'est pas trop long à expliquer je suis preneur.
Merci par avance et bravo pour le travail effectué. 
11-Apr-2010 17:40:19
Les instructions concernant la mise en place sous Linux sont maintenant disponibles ici :

Post a Comment:

You can post a comment here. Please keep it on-topic.




  Note: HTML tags allowed for:b i u strike li ol ul font a p br pre blockquote

This is a technical blog related to the above topic. We reserve the right to remove comments that are off-topic, irrelevant links, advertisements, personal attacks, offensive blogments, etc.

© Nenad Rakocevic - Softinnov