forked from Nik-Hendricks/node.js-sip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDialog.js
27 lines (23 loc) · 938 Bytes
/
Dialog.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//should just offer a way to send a SIP message with the appropriate branch id for the dialog.
//should also offer a way to receive SIP messages and parse them into the appropriate dialog.
//on the implementation side, we should then be able to create a dialog and then register event handlers for the different SIP messages that we expect to receive.
const Builder = require("./Builder");
const Parser = require("./Parser");
const SIPMessage = require("./SIPMessage");
class Dialog{
constructor(context, message){
return new Promise(resolve => {
this.message = message;
this.messages = []
this.branchId = this.message.branchId
this.tag = this.message.tag;
this.events = {};
context.push_to_dialog_stack(this);
resolve(this)
})
}
on(event, callback){
this.events[event] = callback;
}
}
module.exports = Dialog;