From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.142.191.1 with SMTP id o1cs50431wff; Sun, 13 Dec 2009 01:09:47 -0800 (PST) Received: from mr.google.com ([10.91.49.3]) by 10.91.49.3 with SMTP id b3mr5574634agk.23.1260695386680 (num_hops = 1); Sun, 13 Dec 2009 01:09:46 -0800 (PST) Received: by 10.91.49.3 with SMTP id b3mr796910agk.23.1260695385140; Sun, 13 Dec 2009 01:09:45 -0800 (PST) X-BeenThere: rack-devel@googlegroups.com Received: by 10.204.5.70 with SMTP id 6ls718621bku.1.p; Sun, 13 Dec 2009 01:09:43 -0800 (PST) Received: by 10.204.15.20 with SMTP id i20mr96238bka.13.1260695382904; Sun, 13 Dec 2009 01:09:42 -0800 (PST) Received: by 10.204.15.20 with SMTP id i20mr96237bka.13.1260695382876; Sun, 13 Dec 2009 01:09:42 -0800 (PST) Return-Path: Received: from dcvr.yhbt.net (dcvr.yhbt.net [64.71.152.64]) by gmr-mx.google.com with ESMTP id 12si195067bwz.2.2009.12.13.01.09.42; Sun, 13 Dec 2009 01:09:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of normalperson@yhbt.net designates 64.71.152.64 as permitted sender) client-ip=64.71.152.64; Received: from localhost (dcvr.yhbt.net [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPSA id 998101F4ED; Sun, 13 Dec 2009 09:09:41 +0000 (UTC) Date: Sun, 13 Dec 2009 09:09:41 +0000 From: Eric Wong To: rack-devel@googlegroups.com Subject: Re: [ANN/RFC] LMGTWTY - Web Sockets for Rack+Rainbows! Message-ID: <20091213090941.GA19572@dcvr.yhbt.net> References: <20091211201958.GD2121@dcvr.yhbt.net> MIME-Version: 1.0 In-Reply-To: <20091211201958.GD2121@dcvr.yhbt.net> User-Agent: Mutt/1.5.18 (2008-05-17) X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: best guess record for domain of normalperson@yhbt.net designates 64.71.152.64 as permitted sender) smtp.mail=normalperson@yhbt.net X-Original-Sender: normalperson@yhbt.net Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: List-Post: , List-Help: , List-Archive: X-Thread-Url: http://groups.google.com/group/rack-devel/t/1214d460ed982748 X-Message-Url: http://groups.google.com/group/rack-devel/msg/98fe68782f43349e Sender: rack-devel@googlegroups.com List-Unsubscribe: , List-Subscribe: , Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Eric Wong wrote: > For reading, Lmgtwty::IO#gets() returns a single web socket frame. > So it removes the first and last bytes of (\x00 frame \xff) Lmgtwty::IO#gets now also understands the binary framing format, too. This does not appear to be generated by Chrome or pywebsocket, but both understand it. > For writing, Lmgtwty::IO#write(buf) - writes the contents of +buf+ to > the client socket, transparently framing it with "\x00" and "\xff" > bytes. Lmgtwty::IO#write(buf) will now call either Lmgtwty::IO#write_utf8(buf) or Lmgtwty::IO#write_binary(buf) depending on the encoding of +buf+ write(buf) will attempt to use write_utf8(buf) since that seems to be the prevalent framing, under 1.9 just make sure +buf+ is of Encoding::UTF_8. > === Lmgtwty::Request is a subclass of Rack::Request > > It adds a few helper methods to handle handshaking and using > Lmgtwty::IO. I've moved all the logic into a Lmgtwty::WebSocket module, so users of other Rack::Request subclasses (like Sinatra::Request) can also get that stuff included as they wish. > * iobuffer is a C extension gem dependency, I expect replacing it with > a pure Ruby Array of Strings with minimal/no performance loss since > the Strings are expected to be short anyways. The iobuffer dependency is gone with no noticeable performance hit. If you're writing valid UTF-8 (and encoding strings as such under 1.9), then performance has actually improved now (especially if you use write_utf8 directly). > * I've only tested this with the python command-line client. I > avoid GUIs as much as possible and using Chrome at this stage > (without a Vimperator equivalent) would cause me too much pain. At least now I've read the Chrome WebSockets code. -- Eric Wong