Created
January 6, 2019 15:41
-
-
Save radicaldrew/f10e2dff445f09ac50091759d369ae40 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const callControl = require('./node-kamailio-callcontrol')({socket: "/opt/callcontrol/socket", heartbeat: 60000, redis: { server: '127.0.0.1', port: 6379}}); | |
const evapi = require('./node-kamailio-evapi/index')({hostname:"127.0.0.1", port: 8449}); | |
evapi.connect(); | |
evapi.on('connected', () => { | |
console.log('server connected'); | |
}); | |
evapi.on('connecting', (msg) => { | |
console.log(msg); | |
}); | |
evapi.on('data', (request) => { | |
console.log('received data', request); | |
if(request.event !== 'sip-routing') { | |
const response = JSON.stringify({version: "1.0", routing: "none"}); | |
return evapi.response(response); | |
} | |
const response = { | |
version: "1.0", | |
routing: "serial", | |
xtra: { | |
tindex: request.tindex, | |
tlabel: request.tlabel | |
}, | |
routes: [ | |
{ | |
uri: "sip:904@mouselike.org", | |
headers: { | |
extra: "P-App-Name: abc\r\nP-App-Param: bcd\r\n" | |
} | |
}, | |
] | |
}; | |
evapi.response(JSON.stringify(response)); | |
}); | |
callControl.start(); | |
callControl.on('init', (call) => { | |
console.log('received init', call.callid); | |
}); | |
callControl.on('start', (call) => { | |
console.log('received start', call.callid); | |
call.heartbeat.createEvent(1, function(count, last) { | |
console.log(`call ${call.callid} ran for 1 minute...`); | |
call.end(); | |
}); | |
}); | |
callControl.on('stop', (call) => { | |
console.log('received stop', call.callid); | |
}); | |
callControl.on('connection', () => { | |
console.log(`received connection`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment