Commit d28556a7 authored by antirek's avatar antirek

change createServer

parent 0ec9af17
var ding = require('./lib/index'); var AGIServer = require('./lib/index');
var handler = function (context) { var handler = function (context) {
context.onEvent('variables') context.onEvent('variables')
.then(function (vars) { .then(function (vars) {
return context.streamFile('beep'); return context.streamFile('beep');
}); });
}; };
ding.createServer(handler).listen(3000); var agi = new AGIServer(handler);
agi.start(3000);
//ding.createServer(handler).listen(3000);
var Context = require('./context'); var Context = require('./context');
var agi = { var agi = function (handler) {
state: require('./state'),
Context: Context, var server;
createServer: function (handler) {
return require('net').createServer(function (stream) { var handle = function (stream) {
var context = new Context(stream); var context = new Context(stream);
handler(context); handler(context);
}); };
}
var start = function (port) {
server = require('net').createServer(handle).listen(port);
};
return {
start: start
};
}; };
module.exports = agi; module.exports = agi;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment