WebAPI/WebSocketOverApps: Difference between revisions

(Created page with "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 ...")
 
Line 2: Line 2:


== API ==
== API ==
interface WebSocket : EventTarget {
  ...
  // The protocols supported by the client.
  readonly attribute DOMString[] clientProtocols;
  // The server side call this function to start a given protocol; one of clientProtocols.
  void accept(DOMString protocol);
  ...
};
clientProtocols and accept() are added to provide server side features.  clientProtocols is what client side passed as the 2nd argument of WebSocket constructor.  The server side can check this list to find out any one of protocols that is supported by itself.  If not, just skip the request.  If there is any supported protocol, call accept() to start the protocol.
The protocols, here, can be used as the intents or services provided by the server Apps.
=== Client Side ===
=== Client Side ===
  var ws = WebSocket("wsapp://appid/", ["intentAsProtocol"]);
  var ws = new WebSocket("wsapp://appid/", ["intentAsProtocol"]);
  ws.onopen = function () {...};
  ws.onopen = function () {...};
  ws.onerror = function () {...};
  ws.onerror = function () {...};
Confirmed users
398

edits