Comments (4)
Tested out the lastest in master-branch utilizing Q/promises which has a similar issue. In this case however the correct callback is called in time, just with the wrong result in one of the cases.
In this case the result of the operation is
Callback1: 1325376000
Callback2: 1325376000
The code I used following the example in the Readme.md is:
(function () {
'use strict';
var esl = require('./esl/lib/esl');
esl.client( function (eslResponse) {
console.log("...Connected to FS");
eslResponse.sequence([
function () {
this.api('strepoch 2013-01-01').then(function(apiResponse) {
console.log("Callback1: " + apiResponse.body);
return Q(true);
});
}, function () {
return this.api('strepoch 2012-01-01').then(function(apiResponse2) {
console.log("Callback2: " + apiResponse2.body);
return Q(true);
});
}
]);
}).connect(8021, '127.0.0.1');
}());
The full output when running this is:
27 Jun 07:17:05 - { when: 'connection listener emit freeswitch_connect',
call:
{ socket:
{ _events: [Object],
_connecting: false,
_handle: [Object],
_readableState: [Object],
readable: true,
domain: null,
_maxListeners: 10,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
errorEmitted: false,
bytesRead: 0,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
pipe: [Function],
addListener: [Function],
on: [Function],
pause: [Function],
resume: [Function],
read: [Function],
_consuming: true } } }
27 Jun 07:17:05 - { headers: { 'Content-Type': 'auth/request' }, body: undefined }
27 Jun 07:17:05 - { when: 'connection listener socket.emit',
event: 'freeswitch_auth_request',
call:
{ socket:
{ _events: [Object],
_connecting: false,
_handle: [Object],
_readableState: [Object],
readable: true,
domain: null,
_maxListeners: 10,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
errorEmitted: false,
bytesRead: 28,
_bytesDispatched: 0,
_pendingData: null,
_pendingEncoding: '',
pipe: [Function],
addListener: [Function],
on: [Function],
pause: [Function],
resume: [Function],
read: [Function],
_consuming: true },
headers: { 'Content-Type': 'auth/request' },
body: undefined } }
27 Jun 07:17:05 - { when: 'Challenged for authentication' }
27 Jun 07:17:05 - { headers:
{ 'Content-Type': 'command/reply',
'Reply-Text': '+OK accepted' },
body: undefined }
27 Jun 07:17:05 - { when: 'connection listener socket.emit',
event: 'freeswitch_command_reply',
call:
{ socket:
{ _events: [Object],
_connecting: false,
_handle: [Object],
_readableState: [Object],
readable: true,
domain: null,
_maxListeners: 10,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
errorEmitted: false,
bytesRead: 82,
_bytesDispatched: 14,
_pendingData: null,
_pendingEncoding: '',
pipe: [Function],
addListener: [Function],
on: [Function],
pause: [Function],
resume: [Function],
read: [Function],
_consuming: true },
headers:
{ 'Content-Type': 'command/reply',
'Reply-Text': '+OK accepted' },
body: undefined } }
27 Jun 07:17:05 - { when: 'Authentication sent',
call:
{ socket:
{ _events: [Object],
_connecting: false,
_handle: [Object],
_readableState: [Object],
readable: true,
domain: null,
_maxListeners: 10,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
errorEmitted: false,
bytesRead: 82,
_bytesDispatched: 14,
_pendingData: null,
_pendingEncoding: '',
pipe: [Function],
addListener: [Function],
on: [Function],
pause: [Function],
resume: [Function],
read: [Function],
_consuming: true },
headers:
{ 'Content-Type': 'command/reply',
'Reply-Text': '+OK accepted' },
body: undefined } }
...Connected to FS
27 Jun 07:17:05 - { headers: { 'Content-Type': 'api/response', 'Content-Length': '10' },
body: '1356998400' }
27 Jun 07:17:05 - { when: 'connection listener socket.emit',
event: 'freeswitch_api_response',
call:
{ socket:
{ _events: [Object],
_connecting: false,
_handle: [Object],
_readableState: [Object],
readable: true,
domain: null,
_maxListeners: 10,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
errorEmitted: false,
bytesRead: 196,
_bytesDispatched: 64,
_pendingData: null,
_pendingEncoding: '',
pipe: [Function],
addListener: [Function],
on: [Function],
pause: [Function],
resume: [Function],
read: [Function],
_consuming: true },
headers: { 'Content-Type': 'api/response', 'Content-Length': '10' },
body: '1356998400' } }
27 Jun 07:17:05 - { headers: { 'Content-Type': 'api/response', 'Content-Length': '10' },
body: '1325376000' }
27 Jun 07:17:05 - { when: 'connection listener socket.emit',
event: 'freeswitch_api_response',
call:
{ socket:
{ _events: [Object],
_connecting: false,
_handle: [Object],
_readableState: [Object],
readable: true,
domain: null,
_maxListeners: 10,
_writableState: [Object],
writable: true,
allowHalfOpen: false,
onend: null,
destroyed: false,
errorEmitted: false,
bytesRead: 196,
_bytesDispatched: 64,
_pendingData: null,
_pendingEncoding: '',
pipe: [Function],
addListener: [Function],
on: [Function],
pause: [Function],
resume: [Function],
read: [Function],
_consuming: true },
headers: { 'Content-Type': 'api/response', 'Content-Length': '10' },
body: '1325376000' } }
Callback1: 1325376000
Callback2: 1325376000
from esl.
(Sorry for the delay, just came back from vacation.)
In the 0.3.2 test you would have to send the request sequentially by calling eslResponse.api('conference list'..)
from within the callback of the first call to eslResponse.api
.
In the 1.0 version .sequence
should do it for you, but I suspect it gets confused by return Q(true)
. I think return
(or simply omitting the return
statement) should do the trick. Edit: it doesn't, see below for the solution.
from esl.
In 1.0 the proper way to do it is:
(function () {
var esl = require('./esl/lib/esl');
esl.client( function (eslResponse) {
console.log("...Connected to FS");
eslResponse.sequence([
function () {
return this.api('strepoch 2013-01-01');
}
, function() {
console.log("Callback1: " + this.body);
}
, function () {
return this.api('strepoch 2012-01-01');
}
, function() {
console.log("Callback2: " + this.body);
}
]);
}).connect(8021, '127.0.0.1');
}());
from esl.
Obsoleted in 2.x. The proper way to do it would now look like:
@api 'sofia status'
.then (res) ->
console.log res.body
@api 'conference list'
.then (res) ->
console.log res.body
from esl.
Related Issues (20)
- Multiple async calls get mixed up HOT 2
- Unhandled content type "text/rude-rejection" HOT 3
- Moving away from coffeescript? HOT 1
- typescript .d.ts file ? HOT 1
- client.keepConnected does not seem to function properly HOT 4
- removeListener undocumented, doesn't work? HOT 6
- Add client wrapper for auto-reconnect HOT 3
- MaxListenersExceededWarning: (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit. Event name: *. HOT 2
- Question: Detect call rejection in the early media HOT 1
- Basic client not working HOT 6
- Version 10.0.0? HOT 2
- How to subscribe for all events in Client mode ? HOT 2
- Basic server code isn't running HOT 3
- how to get session uuid ? HOT 3
- how can i catch CUSTOM event HOT 2
- Increasing concurrent sockets (Server Mode) HOT 1
- EADDRNOTAVAIL HOT 4
- Example of streaming out and streaming in audio HOT 2
- not close socket connection on server HOT 1
- unable to add logger option in v11 with typescript HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esl.