stardust icon indicating copy to clipboard operation
stardust copied to clipboard

the simplest COMET server I could imagine

                                                                                      +.
                                                                              ..  . +%
                          .                                            .    .  .   .. .
                                            .                         +..- +++.m  .
                .                                        .         .-%m.-++*%.%+..   .
                                                           . -    -+. .####m -.
      WARNING:  alpha quality software  ;)                .+. .   ---#%-m+.. +m .
                                                           .-  .  +mm+-.m+.m .
                                                  + -       -. ...-%-..-. .
                                         - .-     *-. .. . .-..-.--*.mm
                                       . .-.-.-.-- ...-.- -%..m*#.-  .
                                    .    .## m-+ -+%*#.-.%#.#%*#+---.
          .  - .      - .+-. .-  -+-+.-+-.#####.-+-m#%-++-.mm-# -.
     -  -- .. .    - ---+.+++-.*++%-#++-.###+#+#*m###*#.+ .- + -
   .  -+-.   +-+.+m%*-*+#+m-*#*#%###*####%.##*+#m#*###%#%m%-.-. .
. ...... +m .#.m*-m*m###########*#######%#m+%*+m*%####%-+. .
  .m*#%+++++ m#++##########################m+##mm####+m+  .-
 ..##m+-m-%m +-###*######################m#+*m++ m#m.+-+-
.+-*+--..#..m-#############################m+%.m **- -    -.-
 - .-+-+-.m#################################*##*#*-.*-.   % -
  .-+# %#m##############m###########*######*#####.m..      .
 .  m#m################*####################%##mm%++

. -..-####################################+##+.-.- . . ....+- +-#########################m%#%.-%*#+%####-m+-. j

  • #m.-%m#########################%%%++%m%#####%#+#-- . ..#-+#######################%###m%#m*########*%-.#.-.
  • +m##m####################m%#m#%+-#+m#########%#.-. .+##.%#%#########################-#############%.-++ .. %m##############m#####%##########%########+.+. .--.#m##########################%##m######%. . -.##m+%+%###################+####+#######m#+. . -#m%m**%#################################..m . . -m..#######################%#####%###+%+- .-.m-m %-#########m#########+##mm#####m- . .- -.-%m%+-########m*+######%%##++. . m +m.%+++%+%#######+mm##++-%%++.. ..+.-+..m.m+.-..+.-m.m.+.m%.-- .+..%- . .++--. . . .-..

.____________ _________ _____ .__ / /____ _____________ /___ __________ /_ _____ _ / __ `/ / __ / / / / / __/ COMET . / // / / // / / / // / / // /( )/ / Server .// _/ _,/ // _,/ _,/ /___/ _/

CONCEPTS

Channel - channels are the medium through which messages travel. The moment you try to use one, it will be autovivified for you.

Message - messages are arbitrary JSON objects.

You post messages to a channel and if any clients are long-polling on the stream for that channel, those messages will be broadcasted to them.

API

GET /

General info about the server returned as a JSON-encoded object. 

GET /channel

A list of all the channel names that have been used returned as a
JSON-encoded array of strings.

GET /channel/:names

A list of the specified channels returned as a
JSON-encoded array of objects.

(:names is "+" separated string of channel names)

POST /channel/:names

Post a message to the specified channels.

Parameters:

  m   a JSON-encoded object.  If you want to send more than one
      message in a POST, the m parameter may be repeated.

GET /channel/:names/stream/:client_id

Long poll on this URL to subscribe to the specified channels.
When messages become available, they will be returned as a
JSON-ecoded array of objects.