You're not describing a race condition, you're just describing a set of 
sequential asynchronous operations. You just have to nest everything inside 
your exec call.  There are techniques to make it look less ugly, such as 
flattening out your callbacks into named methods and using 
async<https://github.com/caolan/async>
.

The standard solution to an actual race condition is a 
lock<http://en.wikipedia.org/wiki/Lock_(computer_science)>
.

On Tuesday, March 4, 2014 3:57:15 PM UTC-5, Daniel T wrote:
>
> I'm developing a simple app which uses msfnode 
> library<https://github.com/eviltik/msfnode/blob/master/metasploitJSClient.js>that
>  is a metasploit RPC client, so it connects through websockets. This is 
> an example code to use the api to check all consoles opened. As you can 
> see, I add a listener and when it connects, I call the exec function to 
> send one command:
>
> clientmsf.on('connected',function(err,token) {
>     if (err) throw err;    
>     clientmsf.exec(['console.list'], function(err,r){
>         console.log(r);
>     });});
>
> What I want to do is simple: The first thing I have to do is create a 
> console, so I have to send a "console.create" command through the "exec" 
> function that returns me an array with the id. Then, I use that ID to send 
> other commands and thus send and receive information. So, I have a race 
> condition and I don't know how to solve it because I need that ID. I will 
> be very thankful if someone helps me.
>
> Thanks!
>

-- 
-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to