[Twisted-Python] AMP WebSockets bridging
Laurens Van Houtven
_ at lvh.cc
Sat Jun 16 07:45:43 MDT 2012
On Friday, June 15, 2012, Glyph wrote:
>
> On Jun 15, 2012, at 10:13 AM, Laurens Van Houtven wrote:
>
> > Hi,
> >
> > I'm trying to get browsers to communicate with an AMP API.
>
> This is also what <https://launchpad.net/frack> is doing. I hope that it
> becomes a common enough practice that there's a library for it :).
See Allen's comment. It'd certainly be great. Do you think that for old
browsers (that is ie6 & 7) it's acceptable to tell them to go install
chrome frame? ( for Franck and hence twisteds future bug tracker). If the
answer is yes, is that because it will take a while to switch, or would
that also be true today?
Bear in mind that my users are a lot less technical and many are stuck on
winxp because they're corporate machines...
> > The issue is that while AMP is inherently a binary protocol, WebSockets
> transfer text (well, that's a lie: there's a binary version, but it's even
> less widely supported than WebSockets themselves -- and SockJS doesn't
> support it at all, although it's on the roadmap). So, I need an
> alternative, preferably 7-bit, serialization for AMP boxes.
>
> Did you immediately discard the obvious solution of "base64 everything"? :)
Base64 does not fix the problem of encoding and decoding binary responses
on the client side, only on the transport. Binary support (Blob and
ArrayBuffer are those 2 essentially unsupported things. It may be feasible
to build a Unicode amp representation, however meaningless some code points
may then become (that's not a tab stop, it's a length specifier!!)
>
> > An issue I'm running into is an AMP ListOf. With the above code, ListOf
> still gets translated to a string, and obviously I want it to be a list.
> When that ListOf has actual data in it, I get the binary representation.
>
> I would recommend implementing an entirely alternate serialization code
> path; specifically, one which adapts the existing AMP Argument objects to
> some new interface ('.toJSON()'), with a default adapter that uses the
> existing toString()/fromString(), and then specific adapters for those
> interfaces which need modification, like ListOf and Boolean.
I'm not sure I understand at which point that takes effect since apparently
AMP.sendBox is too late?
>
> -glyph
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com <javascript:;>
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>
--
cheers
lvh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/twisted-python/attachments/20120616/26bc01bd/attachment.html>
More information about the Twisted-Python
mailing list