Confirmed users
483
edits
(→Music controls in the lockscreen: Ditto.) |
(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 | // The returned Future will contain an array of Connection objects each | ||
// | // of them representing a connection with a peer through a specific | ||
// keyword. | |||
Promise connectionsRegistered(); | |||
Promise | |||
}; | }; | ||
| 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 '' | 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', | ||
' | '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', | ||
} | } | ||
} | } | ||
| 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. | ||
* '' | * ''rules'' is an object containing a set of constraints to be fulfilled by connection requesters. 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 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; | ||
}; | }; | ||
| 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. | ||
== MessagePort == | == MessagePort == | ||
A ''MessagePort'' is the channel that connects two | 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 = | ||
''' | '''To be done in future versions'''. | ||
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. | |||
= Usage examples = | = Usage examples = | ||
| Line 224: | Line 234: | ||
} | } | ||
}); | }); | ||
= Open Questions = | = Open Questions = | ||