diff --git a/lib/AmiClient.js b/lib/AmiClient.js index 17aab0d..b44e109 100644 --- a/lib/AmiClient.js +++ b/lib/AmiClient.js @@ -295,6 +295,14 @@ class AmiClient extends EventEmitter{ return true; } + /** + * + * @private + */ + _random() { + return Math.floor(Math.random() * (10 ** 10)); + } + /** * * @param prefix @@ -303,7 +311,7 @@ class AmiClient extends EventEmitter{ */ _genActionId(prefix){ prefix = prefix || ''; - return `${prefix}${Date.now()}`; + return `${prefix}${Date.now()}-${this._random()}`; } /** @@ -385,4 +393,4 @@ class AmiClient extends EventEmitter{ } } -module.exports = AmiClient; \ No newline at end of file +module.exports = AmiClient; diff --git a/test/amiClientTest.js b/test/amiClientTest.js index 71be1da..af37166 100644 --- a/test/amiClientTest.js +++ b/test/amiClientTest.js @@ -577,7 +577,8 @@ describe('Ami Client internal functionality', function(){ client = new AmiClient({dontDeleteSpecActionId: true}); client.connect(USERNAME, SECRET, {port: socketOptions.port}).then(() => { client.once('response', response => { - assert.ok(/^--spec_\d{13}$/.test(response.ActionID)); + console.log("actionid = ", response.ActionID); + assert.ok(/^--spec_\d{13}-\d{1,10}$/.test(response.ActionID)); done(); }) .action({Action: 'Ping'});