Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
From: Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org>
To: sunshowers-TBHja+091Wbby3iVrkZq2A@public.gmane.org,
	ruby-talk <ruby-talk-X+L+6nJQZ58h9ZMKESR00Q@public.gmane.org>
Cc: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
Subject: [ANN] Sunshowers - Web Sockets for Ruby, Rack+Rainbows!
Date: Sun, 13 Dec 2009 23:43:20 +0000	[thread overview]
Message-ID: <20091213234320.GB374@dcvr.yhbt.net> (raw)

Sunshowers is a Ruby library for Web Sockets.  It exposes an easy-to-use
API that may be used in both clients and servers.  On the server side,
it is designed to work with Rack::Request and Rainbows! concurrency
models that expose a synchronous application flow.  On the client side,
it may be used as a standalone wrapper for IO-like objects.

* http://rainbows.rubyforge.org/sunshowers/
* sunshowers-TBHja+091Wbby3iVrkZq2A@public.gmane.org
* git://git.bogomips.org/sunshowers.git

It appears works well with the echo_client.py example shipped with
pywebsocket.  It has not been tested against normal web browsers, though
there's no reason it shouldn't work.

== Features

* supports reads and writes of both UTF-8 and binary Web Socket frames

* compatible with Revactor, Rainbows::Fiber::IO and core Ruby IO objects

* pure Ruby implementation, should be highly portable, tested under 1.9

== Install

You may download the tarball from the Rainbows! project page on Rubyforge
and run setup.rb after unpacking it:

http://rubyforge.org/frs/?group_id=8977

You may also install it via RubyGems on Gemcutter:

  gem install sunshowers

== Usage

Make sure you're using one of the following concurrency models
for Rainbows!:

* FiberSpawn
* FiberPool
* Revactor
* ThreadSpawn
* ThreadPool

  # A simple echo server example
  require "sunshowers"
  use Rack::ContentLength
  use Rack::ContentType
  run lambda { |env|
    req = Sunshowers::Request.new(env)
    if req.ws?
      req.ws_handshake!
      ws_io = req.ws_io
      ws_io.each do |record|
        ws_io.write(record)
        break if record == "Goodbye"
      end
      req.ws_quit! # Rainbows! should handle this quietly
    end
    [404, {}, []]
  }

Already using a Rack::Request-derived class?  Sunshowers::WebSocket may
also be included in any Rack::Request-derived class, so you can just
open it up and include it:

  class Sinatra::Request < Rack::Request
    include Sunshowers::WebSocket
  end

See the examples/ directory in the source tree for a client example.

-- 
Eric Wong
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


                 reply	other threads:[~2009-12-13 23:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://yhbt.net/rainbows/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20091213234320.GB374@dcvr.yhbt.net \
    --to=normalperson-rmlxzr9ms24@public.gmane.org \
    --cc=rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org \
    --cc=ruby-talk-X+L+6nJQZ58h9ZMKESR00Q@public.gmane.org \
    --cc=sunshowers-TBHja+091Wbby3iVrkZq2A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhbt.net/rainbows.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).