WebAPI/WebSocketOverApps
< WebAPI
Jump to navigation
Jump to search
WebSocketOverApp API provides WebSocket connections between any pair of Apps on a device. An WebApp can create WebSocket connections to other Apps on the device, so they can pass messages through the connection.
API
Client Side
var ws = WebSocket("wsapp://appid/", ["intentAsProtocol"]);
ws.onopen = function () {...};
ws.onerror = function () {...};
ws.onclose = function () {...};
Server Side =
navigator.mozSetMessageHandler("wsconnect", function (request) {
var ws = request.value;
if (ws.clientProtocols.indexOf("intentAsProtocol") == -1) {
return;
}
ws.accept("intentAsProtocol");
});
Manifest
{
"name": "my application",
...
"wsapp": {
servers: ["server app1", "server app2", ...]
}
}