Skip to content

Commit 9e6b359

Browse files
author
Alessandro Polidori
committed
Initial commit
0 parents  commit 9e6b359

File tree

110 files changed

+29668
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+29668
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# astproxy
2+
3+
Node.js proxy for Asterisk PBX

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('./lib/astproxy');

lib/action.js

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Provides common operations for all asterisk actions.
3+
*
4+
* @class action
5+
* @static
6+
*/
7+
8+
/**
9+
* Separator character to construct ActionID key of the asterisk action.
10+
*
11+
* @property SEP
12+
* @type string
13+
* @default '_'
14+
* @final
15+
* @readOnly
16+
* @private
17+
*/
18+
var SEP = '_';
19+
20+
/**
21+
* Returns the value for the ActionID key of the asterisk action.
22+
*
23+
* @method getActionId
24+
* @static
25+
* @param {string} id The name for the action
26+
* @return {string} Unique value for the ActionID key.
27+
* The value is: id + _ + timestamp
28+
*/
29+
function getActionId(id) {
30+
if (id) {
31+
return id + SEP + (new Date()).getTime() + SEP + Math.floor(Math.random() * 10000);
32+
}
33+
return (new Date()).getTime() + SEP + Math.floor(Math.random() * 10000);
34+
}
35+
36+
/**
37+
* Returns the action name from the ActionID key of the asterisk action.
38+
*
39+
* @method getActionName
40+
* @static
41+
* @param {sring} actionid The value of the ActionID key
42+
* @return {string} The name of the action or undefined
43+
*/
44+
function getActionName(actionid) {
45+
if (actionid && actionid.indexOf(SEP) !== -1) {
46+
return actionid.split(SEP)[0];
47+
}
48+
return undefined;
49+
}
50+
51+
// public interface
52+
exports.getActionId = getActionId;
53+
exports.getActionName = getActionName;

0 commit comments

Comments
 (0)