|
JS
Styx client library written in the JavaScript.
Web applications can use this library to connect to remote Styx servers right from the browser and talk Styx or 9P over HTTP(S). The corresponding web server (e.g. ModLM) transmits Styx messages to the server and back handling the necessary encoding. If you don't know what is a Styx client and server you can start with:
... imagine you have a remote FS mounted to your browser and a simple API to access it. Browser support matrix:
We will port the library to other browsers in the future. High Level InterfaceConsider the following code snippet in JavaScript (e.g. some HTML page): var fs = new StyxFS("/styx", ehandler);
fs.mount("someone", "/net");
var dns = fs.open("/dns", Mode.ORDWR);
var msg = new Message([]);
msg.addString("code.google.com ip");
fs.write(dns, 0, msg.getBytes());
msg = new Message(fs.read(dns, 0, 16));
var ip = msg.getString(0);There is also a working example, which is able to connect to some Styx server and list the root directory contents. ModLM page describes how to install and run the sample application. ImplementationThe JavaScript module consists of the following components:
Connection uses XMLHttpRequest object to implement the actual data exchange. TBD |
Sign in to add a comment