define(function(require) {
'use strict';
var Handler = require('cor/handler');
var smsHandler = require('cor/handlers/sms');
var callHandler;
callHandler = new Handler('call', handleCall, smsHandler);
function handleCall(call) {
console.log('Call placed to number', call.number, 'from number', call.ownNumber);
}
return callHandler;
});
C:\xampp\htdocs\php\js\cor\handlers\sms.js
define(function(require) {
'use strict';
var Handler = require('cor/handler');
var emailHandler = require('cor/handlers/email');
var smsHandler;
smsHandler = new Handler('sms', handleSms, emailHandler);
function handleSms(sms) {
console.log('SMS sent to number', sms.number, 'message: ', sms.message);
}
return smsHandler;
});
C:\xampp\htdocs\php\js\cor\handlers\email.js
define(function(require) {
'use strict';
var Handler = require('cor/handler');
var emailHandler;
emailHandler = new Handler('email', handleEmail, null);
function handleEmail(email) {
console.log('Email sent to', email.recipient, 'message: ', email.message);
}
return emailHandler;
});