unicorn Ruby/Rack server user+dev discussion/patches/pulls/bugs/help
 help / color / mirror / code / Atom feed
From: Bo <boaz@2be.co.il>
To: unicorn-public@bogomips.org
Subject: Please join the Rack Specification discussion for `env['upgrade.websocket']`
Date: Fri, 5 Aug 2016 19:49:17 -0400	[thread overview]
Message-ID: <58D32D89-4523-436E-8C0E-FA8F4E7AFFB2@plezi.io> (raw)

Please join the Rack Specification discussion for `env['upgrade.websocket']`

I represent an effort to extend Rack so that it allows server-side websocket upgrade implementation support and pure Rack websocket applications.

This new Rack feature proposal is gaining support, with over 42 support votes in the [original Rack discussion thread](https://github.com/rack/rack/issues/1093).

You may have read [my blog post about this](https://bowild.wordpress.com/2016/07/31/the-dark-side-of-the-rack/) or [the reddit discussion](https://www.reddit.com/r/ruby/comments/4vgdlc/the_dark_side_of_the_rack_and_websockets_dreams/).

This proposal simplifies Websocket applications by leaving all the network complexity were it is (with the application's web server), allowing application programmers to focus on their application logic.

Using [the proposed specification](https://github.com/boazsegev/iodine/issues/6), a pure Rack Websocket echo server could be written as simply as:

# this is a toy example.
class MyEcho
   def initialize(env = nil)
      # optional initialization
   def on_message(data)
     write "Echo: #{data}"

app = Proc.new do |env|
   if env['upgrade.websocket?'] && env['HTTP_UPGRADE'] =~ /websocket/i
      env['upgrade.websocket'] = MyEcho.new(env) # or simply `MyEcho`
      [ 0, {'X-Header': 'data'}, [] ]
      [200, { 'Content-Length' => '12' }, ['He11o World!']]

run app

There's [a working Gist chatroom example](https://gist.github.com/boazsegev/1466442c913a8dd4271178cab9d98a27).

I invite you to join [the discussion](https://github.com/rack/rack/issues/1093) and help shape the [proposed specification](https://github.com/boazsegev/iodine/issues/6).

             reply	other threads:[~2016-08-05 23:49 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-05 23:49 Bo [this message]
2016-08-06  1:01 ` Please join the Rack Specification discussion for `env['upgrade.websocket']` Eric Wong
2016-08-06  3:09   ` Boaz Segev
2016-08-06  4:10     ` Michael Fischer
2016-08-06  7:37       ` Boaz Segev
2016-08-09  1:08         ` Sam Saffron
2016-08-09  2:42           ` Eric Wong
2016-08-09  3:17           ` Boaz Segev
2016-08-06  4:59     ` Eric Wong

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:

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

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

  git send-email \
    --in-reply-to=58D32D89-4523-436E-8C0E-FA8F4E7AFFB2@plezi.io \
    --to=boaz@2be.co.il \
    --cc=unicorn-public@bogomips.org \


* 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


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).