Skip to content

Instantly share code, notes, and snippets.

@jyap808
Created September 20, 2011 02:29
Show Gist options
  • Save jyap808/1228170 to your computer and use it in GitHub Desktop.
Save jyap808/1228170 to your computer and use it in GitHub Desktop.
from node.js sip.js module
var sip = require('sip');
var udp = require('dgram');
var assert = require('assert');
var util = require('util');
sip.start({}, function(rq) { sip.send(sip.makeResponse(rq, 500)); });
var socket = udp.createSocket('udp4');
socket.bind(6060);
function test1(success) {
socket.on('message',function(msg, rinfo) {
var rs = sip.stringify(sip.makeResponse(sip.parse(msg), 200));
socket.send(new Buffer(rs), 0, rs.length, rinfo.port, rinfo.address);
});
sip.send(
{
method: 'OPTIONS',
uri: 'sip:127.0.0.1:6060;transport=udp',
headers: {
cseq: {method: 'OPTIONS', seq:1},
'call-id': 'hrbtch',
to: {uri: 'sip:test@127.0.0.1'},
from: {uri: 'sip:test@127.0.0.1'}
}
},
function(rs) {
assert.equal(rs.status, 200);
success();
}
);
}
test1(function() { util.log("SUCCESS"); process.exit(0); })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment