This is a hypothetical URL shortener that wants to provide its services to other apps.
The application receives messages sent from Applications that support the #shorten method. The application can process the message and return it back to the calling applications.
A simple list of all the messages that this app has received and processed.
window.channel.initialize(
function() {
var data = {
"name" : "Easy Shorten - URL Shortener"
};
// Register that we are providing an intent.
window.channel.registerIntent("shorten", data, function(message, response) {
// This handler will recieve all messages and process them.
// FAKE shorten the URL
var reverse = text.split("").reverse().join("");
var el = document.createElement("div");
var text = message.data.data + "->" + reverse;
el.textContent = text;
messages.appendChild(el);
// Return some dummy data back to the client app
if(response) {
response({
"data" : reverse
});
}
});
});