WebAPI/Inter App Communication Alt proposal: Difference between revisions

Jump to navigation Jump to search
Get rid of the 'defer' proposal. Introduce the 'Connection' object
(Get rid of the 'defer' proposal. Introduce the 'Connection' object)
Line 14: Line 14:
     Promise connect(DOMString keyword, jsval rules);
     Promise connect(DOMString keyword, jsval rules);
    
    
     // The returned Future will contain ''true'' if at least a peer is allowed
     // The returned Future will contain an array of Connection objects each
     // to communicate with the application, ''false'' otherwise.
     // of them representing a connection with a peer through a specific
     Promise connectionRegistered(DOMString keyword);
     // keyword.
   
     Promise connectionsRegistered();
     Promise getConnectionMessages(DOMString keyword);
   };
   };


Line 24: Line 23:


* ''keyword'' is the key string subject of the connection. Only apps advertising themselves as able to connect through this keyword will receive a connection request (if the user allows to and the app fulfills the requirements specified in the ''rules'' argument).
* ''keyword'' is the key string subject of the connection. Only apps advertising themselves as able to connect through this keyword will receive a connection request (if the user allows to and the app fulfills the requirements specified in the ''rules'' argument).
* ''rules'' is an object containing a set of constraints for the requested connection. Only apps fulfilling these constraints will receive a connection request. These rules may contain:
* ''rules'' (optional) is an object containing a set of constraints for the requested connection. Only apps fulfilling these constraints will receive a connection request. These rules may contain:
** ''minimumAccessLevel'' is the minimum level of access (one of https://developer.mozilla.org/en-US/docs/Web/Apps/Manifest#type) that the receiver app requires in order to be able to receive the connection request. The default value will be 'web'.
** ''minimumAccessLevel'' is the minimum level of access (one of https://developer.mozilla.org/en-US/docs/Web/Apps/Manifest#type) that the receiver app requires in order to be able to receive the connection request. The default value will be 'web'.
** ''origin'' (array) can be used to set specific receivers by a list of origins.
** ''origin'' (array) can be used to set specific receivers by a list of origins.
Line 30: Line 29:


== Receiver ==
== Receiver ==
Applications can advertise themselves as able to connect given an specific keyword by adding an entry named ''connection'' in the manifest containing an object list where each object represents the description and details of each potential connection.
Applications can advertise themselves as able to connect given an specific keyword by adding an entry named ''connections'' in their manifests containing an object list where each object represents the description and details of each potential connection.


   {
   {
Line 39: Line 38:
         'handler_path': '/handler1.html',
         'handler_path': '/handler1.html',
         'description': 'Do something for keyword1 connection',
         'description': 'Do something for keyword1 connection',
         'deferQueue': true
         'rules': {
          'minimumAccessLevel': 'web',
          'origin': ['origin_1', 'origin_n'],
          'developer': [{
            'name': 'developer_name',
            'url': 'developer_url'
          }]
        }
       },
       },
       'keyword2': {
       'keyword2': {
         'handler_path': '/handler2.html',
         'handler_path': '/handler2.html',
         'description': 'Do something for keyword2 connection',
         'description': 'Do something for keyword2 connection',      
        'defer': false
       }
       }
     }
     }
Line 53: Line 58:
* ''handler_path'' is the path of the page where the handler of the connection request lives in the app's code. If 'handling_path' is absent, the 'launch_patch' will be taken as default.
* ''handler_path'' is the path of the page where the handler of the connection request lives in the app's code. If 'handling_path' is absent, the 'launch_patch' will be taken as default.
* ''description'' is the message to be shown to the user during the connection request that should describe why the connection is required and what does the app intends to do within that connection.
* ''description'' is the message to be shown to the user during the connection request that should describe why the connection is required and what does the app intends to do within that connection.
* ''defer'' is a flag to allow apps to be woken up because of a connection request. If 'defer' is not present, it will default to true. The 'defer' value will be ignored if the connection has not being previously accepted by the user and the receiver which will be woken up so it can handle and properly accept the connection request.
* ''rules'' is an object containing a set of constraints to be fulfilled by connection requesters. These rules may contain:
* ''deferQueue'' is a flag that indicates if an app expects to keep a queue of messages received while it is not being executed or has no handler for the messages. An app may choose to ignore messages sent to it while it is not being executed. If ''deferQueue'' is not present, false will be taken as the default value.
** ''minimumAccessLevel'' is the minimum level of access (one of https://developer.mozilla.org/en-US/docs/Web/Apps/Manifest#type) that the requester app requires in order to be able to send a connection request. The default value will be 'web'.
** ''origin'' (array) can be used to set specific requesters by a list of origins.
** ''developer'' (array) list of objects identifying app authors whose apps are allowed to send connection requests.


=== Connection acknowledgement ===
=== Connection acknowledgement ===
Line 62: Line 69:
     MessagePort port;
     MessagePort port;
     DOMString  keyword;
     DOMString  keyword;
    jsval      callerInfo;
    void        reject();
   };
   };


Line 70: Line 75:
* ''port'' is an instance of ''MessagePort'' that will be the message channel for the connection.
* ''port'' is an instance of ''MessagePort'' that will be the message channel for the connection.
* ''keyword'' is the key string given with the ''.connect()'' call.
* ''keyword'' is the key string given with the ''.connect()'' call.
* ''callerInfo'' is an object containing basic information about the app requesting the connection channel. This information will allow the receiver to decide if the connection is secure enough or not. It may contain the following data ('''TODO:''' we need to decide which data do we want to provider. We might want to provide the whole caller app manifest):
** ''origin'' which is the origin of the app requesting the connection.
** ''accessLevel'' which is the [https://developer.mozilla.org/en-US/docs/Web/Apps/Manifest#type access level] of the app requesting the connection.
** ''developer'' which contains the information about the developer of the app requesting the connection. It may contain the name and url of the developer.


== MessagePort ==
== MessagePort ==
A ''MessagePort'' is the channel that connects two apps and allow them to send and receive messages.
A ''MessagePort'' is the channel that connects two applications and allow them to send and receive messages.


   interface MessagePort {
   interface MessagePort {
Line 82: Line 83:
     attribute jsval onmessage;
     attribute jsval onmessage;
   };
   };
== Connection ==
A ''Connection'' object represents a connection between two apps through an specific keyword.
interface Connection {
  readonly attribute DOMString publisher;
  readonly attribute DOMString subscriber;
  cancel();
};
= Defer mechanism =
= Defer mechanism =
'''TODO'''
'''To be done in future versions'''.


== Offline message queues ==
The fact that the implementation of this API is based in System Messages leaves us in a situation where potential performance issues might appear if several applications advertise themselves as able to connect through the same keyword and so are targets of the same connection request. In that case, a defer mechanism where apps are forced to specify that they really need to be woken up to handle a connection request might help to mitigate this issue.
'''TODO'''


= Usage examples =
= Usage examples =
Line 224: Line 234:
   }
   }
  });
  });
== Other use case ==
'''TODO'''


= Open Questions =
= Open Questions =
Confirmed users
483

edits

Navigation menu