Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds "onRawEventUnmarshalled" can specify AMI Login Events param #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/message/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,18 @@ var ActionUniqueId = (function() {
* @constructor
* @param {String} username The username. The value of the "Username" key.
* @param {String} secret The password. The value of the "Secret" key.
* @param {String} a comma delimited list of Events to subscribe to. Example: "call,hud" will subscribe to all call and hud events.
* @see Action(String)
* @see See <a href="https://wiki.asterisk.org/wiki/display/AST/ManagerAction_Login">https://wiki.asterisk.org/wiki/display/AST/ManagerAction_Login</a>.
* @augments Action
*/
function Login(username, secret) {
function Login(username, secret, events) {
Login.super_.call(this, 'Login');
this.set('Username', username);
this.set('Secret', secret );
if( events !== undefined ) {
this.set('Events', events);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: where is this documented? i knew about the Events action but not about this argument.. couldn't find it documented in the asterisk wiki and others.

}
}
/**
* CoreShowChannels Action.
Expand Down
5 changes: 3 additions & 2 deletions src/nami.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ Nami.prototype.onRawMessage = function (buffer) {
if (buffer.match(/^Event: /) !== null) {
event = new namiEvents.Event(buffer);
this.emit('namiRawEvent', event);
this.emit('namiRawEventUnmarshalled', buffer); // This includes the raw event unmarshalled with \r\n etc still intact
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mm i think it would suffice with the above event (namiRawEvent).. otherwise we would be emitting lots of events.. just for special cases, like debugging

} else if (buffer.match(/^Response: /) !== null) {
response = new namiResponse.Response(buffer);
this.emit('namiRawResponse', response);
Expand Down Expand Up @@ -183,7 +184,7 @@ Nami.prototype.onClosed = function () {
* On successfull connection, "namiConnected" is emitted.
* @param {String} data The data read from server.
* @see Nami#onData(String)
* @see Login(String, String)
* @see Login(String, String, String)
* @returns void
*/
Nami.prototype.onWelcomeMessage = function (data) {
Expand All @@ -197,7 +198,7 @@ Nami.prototype.onWelcomeMessage = function (data) {
self.onData(data);
});
this.send(
new action.Login(this.amiData.username, this.amiData.secret),
new action.Login(this.amiData.username, this.amiData.secret, this.amiData.events),
function (response) {
if (response.response !== 'Success') {
self.emit('namiLoginIncorrect');
Expand Down