Every VM has multiple server objects
- they make up the httpl:// namespace
- may be functions or objects with a
handleLocalRequest
method
"Bridge" servers wrap the postMessage
interfaces
- a request to
httpl://the-worker
ispostMessage
ed - the worker generates a response
- the response is
postMessage
ed back
Bridges have two handlers: local and remote
handleLocalRequest
does the serialize andpostMessage
. It takes requests from the local VMhandleRemoteRequest
generates responses topostMessage
back. It takes requests from the other VM- for bridges, applications only define a
handleRemoteRequest
becausehandleLocalRequest
is standard: it always serializes the request and sends it to be fulfilled by the other VM'shandleRemoteRequest
Workers define all behaviors in their handleRemoteRequest
, but they can proxy to other httpl hosts within their VM.
- in the worker:
local.addServer('config', require("config-server.js"));
myBridgeServer.proxy('/config', 'httpl://config');
- now
httpl://the-worker/config
is handled by config-server