### use() middleware registration examples Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf.md Registers middleware for all SIP methods and for the 'invite' method specifically. The first example sets up a default middleware that initializes req.locals; the second adds invite-only middleware. ```javascript srf.use((req, res, next) => { req.locals = req.locals || {}; next(); }); srf.use('invite', (req, res, next) => { /* invite-only middleware */ }); ``` -------------------------------- ### connect(opts, callback) - Usage Example Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf.md Example of connecting to a drachtio server. The callback receives an error and the hostport string; on error, it logs the failure, otherwise it logs the connected hostport. ```javascript srf.connect({host: '127.0.0.1', port: 9022, secret: 'cymru'}, (err, hostport) => { if (err) return console.error(`connect failed: ${err}`); console.log(`connected to drachtio server listening on ${hostport}`); }); ``` -------------------------------- ### app.listen(opts, callback) usage Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/app.md Starts the app listening for incoming requests. Returns the net.Server instance. ```javascript app.listen(opts, callback) ``` -------------------------------- ### listen(opts, callback) - Usage Example Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf.md Example of putting the Srf in listen mode. Creates a new Srf instance with a tag, listens on port 3001, and logs the hostport when drachtio servers connect. ```javascript const srf = new Srf('tag-value'); srf.listen({port: 3001, secret: 'cymru'}, (err, hp) => { if (err) throw err; console.log(`listening for drachtio connections that will offer endpoints ${hp}`); }); ``` -------------------------------- ### listen(...args) Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/app.md Starts listening for incoming connections. ```APIDOC ## `listen(...args)` ### Description Starts listening for incoming connections. Calls `_init()` then `client.listen(...)`. Returns the `net.Server`. ### Method `listen` ### Parameters - **opts** (object) - Required - Listen options. - **callback** (function) - Optional - Callback invoked when listening starts. ### Returns - **server** (net.Server) - The underlying server. ``` -------------------------------- ### proxy() setup options computation Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/request.md Shows how proxy options are computed internally, including stackTxnId, remainInDialog, provisionalTimeout, finalTimeout, followRedirects, simultaneous, and fullResponse. ```javascript Object.assign(opts, { stackTxnId: this.stackTxnId, remainInDialog: opts.remainInDialog || opts.path || opts.recordRoute || false, provisionalTimeout: opts.provisionalTimeout || '', finalTimeout: opts.finalTimeout || '', followRedirects: opts.followRedirects || false, simultaneous: opts.forking === 'simultaneous', fullResponse: true }); ``` -------------------------------- ### Listen to Srf events: connect and cdr:start Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf.md Example of attaching listeners to the 'connect' and 'cdr:start' events on the Srf instance. The 'connect' handler logs an error if connection fails, otherwise logs the hostport. The 'cdr:start' handler logs the source and role. ```javascript srf.on('connect', (err, hp) => { if (err) return console.error(`error connecting: ${err}`); console.log(`connected to ${hp}`); }); srf.on('cdr:start', (source, time, role, msg) => { console.log(`cdr start: ${source} ${role}`); }); ``` -------------------------------- ### Example: send 180 and 200 responses Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/response.md Example of sending a 180 Ringing response and then a 200 OK after a delay, with headers and body. ```javascript srf.invite((req, res) => { res.send(180, 'Ringing'); setTimeout(() => { res.send(200, 'OK', { headers: {'User-Agent': 'my-app'}, body: mySdp }, (err, msg) => { if (err) return console.error(`final response failed: ${err}`); }); }, 2000); }); ``` -------------------------------- ### Create Srf with external app (deprecated) Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/app.md Use this deprecated constructor form when you need to create an Srf instance from an externally created app. The Srf requires manual middleware wiring: you must install srf.dialog() yourself and then set up your own invite handler and connect call. Note that the example references legacy method names (createUacDialog, createUasDialog, createBackToBackDialogs, modifySession) that are not defined in the current lib/ source; the current API uses createUAC, createUAS, createB2BUA, and Dialog#modify. ```js const app = require('drachtio-srf/lib/connect')(); const Srf = require('drachtio-srf'); const srf = new Srf(app); // deprecated constructor form app.use(srf.dialog()); // must be installed manually app.invite((req, res) => { ... }); app.connect({host: '127.0.0.1', port: 8022, secret: 'cymru'}); ``` -------------------------------- ### Middleware registration and connect example Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/app.md Shows how to register middleware with app.use and connect to a drachtio server. The first middleware sets a custom token, the second handles INVITE requests with a 404 response. ```javascript const app = createServer(); app.use((req, res, next) => { req.myToken = 'x'; next(); }); app.use('invite', (req, res) => { res.send(404, 'Not Here'); }); app.connect({host: '127.0.0.1', port: 9022, secret: 'cymru'}); ``` -------------------------------- ### createUAC basic usage Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf-dialogs.md Example of creating a UAC dialog with an initial SDP offer and handling progress callbacks and finalization. ```js const mySdp = 'v=0 ...'; // offer srf.createUAC('sip:1234@10.10.100.1', {localSdp: mySdp}, { cbRequest: (reqSent) => { inviteSent = reqSent; }, cbProvisional: (res) => console.log(`got 1xx: ${res.status}`) }).then((uac) => { console.log(`dialog established, call-id is ${uac.sip.callId}`); uac.on('destroy', () => console.log('called party hung up')); }).catch((err) => { if (err instanceof Srf.SipError) console.log(`INVITE rejected with status: ${err.status}`); }); ``` -------------------------------- ### Srf constructor usage examples Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf.md Shows different ways to instantiate Srf: with no tags, a single tag, multiple tags, or connection options for immediate connection. ```javascript const srf = new Srf(); // no tags const srf = new Srf('my-app'); // single tag const srf = new Srf(['app1', 'app2']); // up to 20 tags const srf = new Srf({host: '127.0.0.1', port: 9022, secret: 'cymru'}); // connect immediately ``` -------------------------------- ### SipMessage usage example Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/sipmessage.md Example usage of the SipMessage class. Creates a new SipMessage from a raw SIP string and demonstrates accessing the method, parsed headers, and calling number. ```javascript const msg = new SipMessage(rawInviteString); console.log(msg.method); // INVITE console.log(msg.getParsedHeader('from').uri); // sip:alice@example.com console.log(msg.getParsedHeader('via').length); // >= 1 console.log(msg.callingNumber); // 4083084809 ``` -------------------------------- ### Example: reject and challenge responses Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/response.md Shows how to reject a call with 486 and comments on internal usage for 401/407 and reliable provisional responses. ```javascript // reject a call srf.invite((req, res) => { res.send(486, 'Busy Here'); }); // challenge (401/407) and reliable provisional usage internally: // res.send(183, 'Session Progress', {headers: {'Require': '100rel', 'RSeq': '1'}}, null, onPrack) ``` -------------------------------- ### Example Back-to-back user agent Source: https://github.com/drachtio/drachtio-srf/blob/main/README.md Creates a back-to-back user agent (B2BUA) that connects an incoming INVITE to a specified SIP URI, using the request body as the local SDP. Hangs up the other leg when one side terminates, and logs connection failures. ```JavaScript const Srf = require('drachtio-srf'); const srf = new Srf(); srf.connect({ host: '192.168.32.5', port: 9022, secret: 'cymru' }); const Srf = require('drachtio-srf'); const srf = new Srf(); srf.invite((req, res) => { srf.createB2BUA('sip:1234@10.10.100.1', req, res, {localSdpB: req.body}) .then(({uas, uac}) => { console.log('call connected'); // when one side terminates, hang up the other uas.on('destroy', () => { uac.destroy(); }); uac.on('destroy', () => { uas.destroy(); }); return; }) .catch((err) => { console.log(`call failed to connect: ${err}`); }); }); ``` -------------------------------- ### proxy() usage example with simultaneous forking Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/request.md Shows proxying an incoming INVITE to two destinations with simultaneous forking, provisional timeout of 1500ms, final timeout of 30s, and followRedirects enabled. Logs the connected status and final status. ```javascript srf.invite((req, res) => { req.proxy({ destination: ['sip:1.2.3.4:5060', 'sip:1.2.3.5:5060'], forking: 'simultaneous', provisionalTimeout: '1500ms', finalTimeout: '30s', followRedirects: true }).then((results) => { console.log(`connected: ${results.connected}, final status: ${results.finalStatus}`); }).catch((err) => console.error(`proxy error: ${err}`)); }); ``` -------------------------------- ### createUAS Promise usage Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf-dialogs.md Example of using createUAS with a Promise to handle dialog establishment. ```js srf.invite((req, res) => { srf.createUAS(req, res, {localSdp: mySdp}) .then((uas) => { console.log(`dialog established, remote uri is ${uas.remote.uri}`); uas.on('destroy', () => console.log('caller hung up')); }) .catch((err) => console.log(`Error establishing dialog: ${err}`)); }); ``` -------------------------------- ### Example sending a request (OPTIONS ping) Source: https://github.com/drachtio/drachtio-srf/blob/main/README.md Sends an OPTIONS request every 10 seconds to a specified SIP URI after connecting to the drachtio server. Logs connection errors, the server address, and the response status of each OPTIONS ping. ```JavaScript const Srf = require('drachtio-srf'); const srf = new Srf(); srf.connect({host: '127.0.0.1', port: 9022, secret: 'cymru'}); srf.on('connect', (err, hp) => { if (err) return console.log(`Error connecting: ${err}`); console.log(`connected to server listening on ${hp}`); setInterval(optionsPing, 10000); }); function optionsPing() { srf.request('sip:tighthead.drachtio.org', { method: 'OPTIONS', headers: { 'Subject': 'OPTIONS Ping' } }, (err, req) => { if (err) return console.log(`Error sending OPTIONS: ${err}`); req.on('response', (res) => { console.log(`Response to OPTIONS ping: ${res.status}`); }); }); } ``` -------------------------------- ### Modify with new SDP and error handling Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/dialog.md Example of renegotiating media by offering a new SDP with a custom `X-Reason` header. On success, logs the remote SDP; on failure, checks for a `SipError` and logs the status code. ```javascript try { const remoteSdp = await uac.modify(newSdp, {headers: {'X-Reason': 'codec-upgrade'}}); console.log(`renegotiated, remote now: ${remoteSdp}`); } catch (err) { if (err instanceof Srf.SipError) console.error(`re-INVITE rejected: ${err.status}`); } ``` -------------------------------- ### Example proxy Source: https://github.com/drachtio/drachtio-srf/blob/main/README.md Connects to a drachtio server and handles an INVITE by proxying the request to two destinations with options for record routing, redirect following, and a provisional timeout. Logs the final result object. ```JavaScript const Srf = require('drachtio-srf'); const srf = new Srf(); srf.connect({ host: '192.168.32.5', port: 9022, secret: 'cymru' }); srf.invite((req, res) => { srf.proxyRequest(req, ['sip.example1.com', 'sip.example2.com'], { recordRoute: true, followRedirects: true, provisionalTimeout: '2s' }).then((results) => { console.log(JSON.stringify(result)); // {finalStatus: 200, finalResponse:{..}, responses: [..]} }); }); ``` -------------------------------- ### request() with callback and response event Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf.md Sends an OPTIONS request using a callback. The callback receives an error or the sent request; listen for the `response` event to get the SIP response. Logs the status code when the response arrives. ```javascript srf.request('sip:example.com', {method: 'OPTIONS'}, (err, req) => { if (err) return console.error(`request failed: ${err}`); req.on('response', (res) => { console.log(`OPTIONS answered with ${res.status}`); }); }); ``` -------------------------------- ### set(prop, value) / get(prop) Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf.md Delegated to the app's params store; set writes this.params[prop], get reads it. ```APIDOC ## set(prop, value) / get(prop) ### Description Delegated to the app's params store. `set(prop, value)` writes `this.params[prop]`; `get(prop)` reads it. `set('handler', fn)` on the agent is special-cased to swap the middleware handler. `_app.set('handler', handler)` is used by integration frameworks. ### Parameters - **prop** (string) - Required - The property name. - **value** (any) - Required for set - The value to set. ### Returns - For `get`: the value of the property, or undefined if not set. ### Source `lib/proto.js` ``` -------------------------------- ### set(prop, val) / get(prop) Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/drachtio-agent.md set stores arbitrary parameters in a Map, except for 'handler' which replaces the middleware dispatcher. get reads parameters from the Map. ```APIDOC ## set(prop, val) / get(prop) ### Description `set` stores arbitrary params (Map) except `'handler'`, which replaces `puntUpTheMiddleware` (the middleware dispatcher). `get` reads params. ### Parameters - **prop** (string) - Required - The property name to set or get. - **val** (any) - Required for set - The value to store. ### Returns - **get** returns the stored value for the given property. ``` -------------------------------- ### _init() Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/app.md Initializes the DrachtioAgent and sets up event forwarding and delegation. ```APIDOC ## `_init()` ### Description Creates the `DrachtioAgent` (`this.client`), copies `this.params` into it via `client.set`, routes all `routedMethods` via `client.route(method)`, forwards agent events (`connect`, `close`, `error`, `reconnecting`, `listening`) and cached cdr events to the app's own emitters, and delegates `request`, `disconnect`, `close`, `get`, `set` and the `idle` getter to the client. Returns the client. ### Method `_init` ### Parameters None ### Returns - **client** (DrachtioAgent) - The created client. ``` -------------------------------- ### connect(opts, callback) Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/drachtio-agent.md Client mode: creates a WireProtocol and connects TCP/TLS to the drachtio server, then authenticates. On success emits 'connect'; on failure emits 'connect' with an Error. If a callback is supplied, it is subscribed to the 'connect' event. ```APIDOC ## connect(opts, callback) ### Description Client mode: create a WireProtocol, connect TCP/TLS to the drachtio server, and authenticate. On authentication success the agent emits `connect`; on failure, `connect` is emitted with `Error('failed to authenticate to server')`. If `callback` is supplied it is subscribed to the `connect` event. ### Method connect ### Parameters - **opts** (object) - Required - Configuration options for the connection. See configuration.md for details. - **callback** (function) - Optional - Subscribed to the `connect` event. ### Events - **connect** - Emitted on successful authentication. - **connect** with Error - Emitted on authentication failure with `Error('failed to authenticate to server')`. ### Example ```js connect(opts, callback) ``` ``` -------------------------------- ### Manual PRACK handling example Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/response.md Example of manually sending a PRACK in response to a reliable provisional response (with RSeq header). Normally handled internally via the ack function, but shown here for manual control. ```javascript req.on('response', (res, ack) => { if (res.status >= 200 && res.status < 300 && res.has('RSeq')) { // manual PRACK (normally handled internally via the ack function) res.sendPrack(dialogId, {}, (err) => { /* ... */ }); } }); ``` -------------------------------- ### listening Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/drachtio-agent.md Emitted in server mode when the agent starts listening. ```APIDOC ## Event: listening ### Description Forwarded in server mode. ### Signature No parameters. ``` -------------------------------- ### Create app with createServer() Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/app.md Imports the createServer factory from drachtio-srf/lib/connect and creates the app function. The app is callable as app(req, res, next) and is merged with proto methods, EventEmitter, and internal properties. ```javascript const createServer = require('drachtio-srf/lib/connect'); const app = createServer(); ``` -------------------------------- ### app.connect(opts, callback) usage Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/app.md Connects the app to a drachtio server. Returns the app instance, not a Promise. ```javascript app.connect(opts, callback) ``` -------------------------------- ### Create and connect Srf instance Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf.md Imports the Srf class, creates an instance, connects to a drachtio server, and registers an INVITE handler. ```javascript const Srf = require('drachtio-srf'); const srf = new Srf(); srf.connect({ host: '127.0.0.1', port: 9022, secret: 'cymru' }); srf.invite((req, res) => { // handle an inbound INVITE }); ``` -------------------------------- ### authenticate(callback) signature Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/digest-client.md Starts the authentication flow. The callback is invoked when credentials resolve, receiving the newly-sent request. ```javascript authenticate(callback) ``` -------------------------------- ### createUAC cancel request Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf-dialogs.md Example of cancelling an unanswered INVITE request using the request object captured in the progress callback. ```js // cancel an unanswered INVITE using the progress callback let inviteSent; srf.createUAC('sip:1234@10.10.100.1', {localSdp: mySdp}, {cbRequest: (req) => { inviteSent = req; }}) .then((uac) => console.log('connected before cancel')) .catch((err) => { if (err instanceof Srf.SipError && err.status === 487) console.log('expected: INVITE cancelled'); }); setTimeout(() => inviteSent.cancel(), 500); // CANCEL the outstanding INVITE ``` -------------------------------- ### connect(opts) Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/wire-protocol.md Establishes a client-mode connection to a drachtio server. Honors host, port, reconnect, tls, enablePing, and pingInterval options. Throws an AssertionError if the instance is already in server mode. ```APIDOC ## connect(opts) ### Description Establishes a client-mode connection to a drachtio server. Honors host, port, reconnect, tls, enablePing, and pingInterval options. Throws an AssertionError if the instance is already in server mode. ### Parameters - **opts.host** (string) - Required - The hostname or IP address of the drachtio server. - **opts.port** (number) - Required - The port number of the drachtio server. - **opts.reconnect** (boolean) - Optional - Whether to enable reconnection with backoff. - **opts.tls** (object) - Optional - TLS options object; if provided, a tls.connect socket is created, otherwise net.connect is used. - **opts.enablePing** (boolean) - Optional - Whether to enable pings. - **opts.pingInterval** (number) - Optional - The ping interval in milliseconds. ### Behavior - Sockets get setNoDelay(true) and setKeepAlive(true). - Throws AssertionError ('cannot be both client and server') if this.server is already set. - Reconnect variables are seeded up front. ### Example ```js wp.connect({ host: '127.0.0.1', port: 9022, reconnect: true, enablePing: true, pingInterval: 5000 }); ``` ``` -------------------------------- ### Get app getter definition Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf.md Shows the getter syntax for the app property, which returns the internal app object created by lib/connect.js createServer. ```javascript get app() ``` -------------------------------- ### connect(opts, callback) signature Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/drachtio-agent.md Client mode: creates a WireProtocol, connects TCP/TLS to the drachtio server, and authenticates. On success emits 'connect'; on failure emits 'connect' with Error('failed to authenticate to server'). If callback is supplied, it is subscribed to the 'connect' event. ```javascript connect(opts, callback) ``` -------------------------------- ### Basic client connection Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/configuration.md Connects a drachtio-srf client to a drachtio server using host, port, and secret. This is the minimal setup for a client connection. ```javascript // Basic client connection const srf = new Srf('my-app'); srf.connect({host: '127.0.0.1', port: 9022, secret: 'cymru'}); ``` -------------------------------- ### connect(...args) Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/app.md Connects the app to a Drachtio server. ```APIDOC ## `connect(...args)` ### Description Connects the app to a Drachtio server. Calls `_init()` then `client.connect(...)`. Returns the app (not a Promise). ### Method `connect` ### Parameters - **opts** (object) - Required - Connection options (e.g., `host`, `port`, `secret`). - **callback** (function) - Optional - Callback invoked when connection is established. ### Returns - **this** (app) - The app instance. ``` -------------------------------- ### connect(opts, callback) Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf.md Connects to a drachtio server using the given options and invokes the callback when the connection succeeds or fails. ```APIDOC ## `connect(opts, callback)` ### Description Connects to a drachtio server using the given options and invokes the callback when the connection succeeds or fails. ### Method connect ### Parameters - **opts** (`Srf.SrfConfig`) - Optional - Connection options. `host` defaults to `127.0.0.1`, `port` to `9022`. See configuration.md. - **callback** (`(err: Error, hostport: string, serverVersion?: string, localHostports?: any) => void`) - Optional - Invoked when the `connect` event fires. ### Returns Returns the underlying app object (not a Promise) at runtime; the bundled type declarations describe a `Promise` return. When tags were supplied at construction, they are merged into the opts as `{tags: [...]}` before connecting. ### Example ```js srf.connect({host: '127.0.0.1', port: 9022, secret: 'cymru'}, (err, hostport) => { if (err) return console.error(`connect failed: ${err}`); console.log(`connected to drachtio server listening on ${hostport}`); }); ``` ``` -------------------------------- ### createUAS callback usage with custom headers Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/srf-dialogs.md Example of using createUAS with a callback, including custom SIP headers and handling of 487 Request Terminated errors. ```js // custom headers + cancel handling srf.invite((req, res) => { srf.createUAS(req, res, { localSdp: mySdp, headers: {'User-Agent': 'drachtio/iechyd-da', 'X-Linked-UUID': '1e2587c'} }, (err, uas) => { if (err) { if (err instanceof Srf.SipError && err.status === 487) { return console.log('caller hung up before answer'); } return console.error(`failed: ${err}`); } uas.on('destroy', () => /* tear down */); }); }); ``` -------------------------------- ### Listen mode (drachtio connects outbound to us), TLS Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/configuration.md Starts a listen server where drachtio connects outbound to this application. Uses TLS with key and certificate files for secure communication. ```javascript // Listen mode (drachtio connects outbound to us), TLS srf.listen({ port: 3001, host: '0.0.0.0', secret: 'cymru', tls: {key: fs.readFileSync('key.pem'), cert: fs.readFileSync('cert.pem')} }); ``` -------------------------------- ### constructor(opts) Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/wire-protocol.md Creates a new WireProtocol instance. The opts.logger parameter receives wire-level debug traces. ```APIDOC ## constructor(opts) ### Description Creates a new WireProtocol instance. The opts.logger parameter receives wire-level debug traces. ### Parameters - **opts.logger** (function) - Optional - Receives wire-level <=== / ===> debug traces (the SrfConfig.logger option). Default is noop. ### Example ```js const WireProtocol = require('drachtio-srf/lib/wire-protocol'); const wp = new WireProtocol({ logger: (msg) => console.log(msg) }); ``` ``` -------------------------------- ### Parse a SIP URI with transport parameter Source: https://github.com/drachtio/drachtio-srf/blob/main/_autodocs/api-reference/sipmessage.md Example of parsing a SIP URI with a transport parameter. The returned object shows the parsed fields; note the user includes the '+' prefix. ```javascript const u = Srf.parseUri('sip:+15083084807@192.168.1.100:5080;transport=tcp'); // { family: 'ipv4', scheme: 'sip', user: '+15083084807', host: '192.168.1.100', // port: 5080, params: { transport: 'tcp' }, headers: {} } ```