Skip to content

vaizguy/amphibian

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 

Repository files navigation

amphibian

amphibian is JSON-RPC to AMP bridge.

image

Why?

AMP is an awesome protocol, but it's inherently binary. While binary support in browsers is improving (ArrayBuffer and Blob), they're still nowhere near widely supported and using them for anything other than their immediate use case (WebGL and the File API, respectively) is incredibly annoying.

Bottom line: anything you send across the WebSocket wire better be 7-bit safe.

Although base64 seems like the obvious solution, you still lack the tools to parse and produce those AMP boxes.

At the same time, browsers everywhere speak JSON, and usually pretty efficiently, too. JSON has a de facto RPC protocol called JSON-RPC which is very similar in many ways to AMP. Hence, it made sense to attempt to proxy them.

How it works

amphibian supports JSON-RPC 2.0 encoded as netstrings (the standard for JSON-RPC 2.0 over TCP) over anything you can specify as an endpoint, and, more importantly, JSON-RPC 2.0 encoded as netstrings over WebSockets.

Differences

The main difference is that JSON-RPC takes positional arguments whereas AMP generally takes named keyword arguments (with the exception of protocol switching). To fix this, amphibian requires the JSON-RPC parameters array to consist of a single JSON object that has the keyword arguments for the AMP call:

{jsonrpc: "2.0", method: "Command", params: [{x: 1}]}

This maps to:

ampClient.callRemote(Command, x=1)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%