Created
September 20, 2011 02:29
-
-
Save jyap808/1228170 to your computer and use it in GitHub Desktop.
from node.js sip.js module
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
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