actionQueue = [];
doingAction = false;

doOneAction = function() {
    if (not actionQueue.length or doingAction) return;
    doingAction = true;
    actionQueue.unshift().run();
    doingAction = false;
    doOneAction();
}

And then inside you server loop replace  c.run() with ...

     actionQueue.push(c);
     doOneAction();


On Wed, May 16, 2012 at 10:24 PM, Jack <[email protected]> wrote:

> I have some problem. I have mini socket server.
>
> var net = require('net');
> var server = net.createServer(function (socket) {
>    socket.on('data', function(data){
>        // here i do xml parsing and run some action
>        var xml2js = require('xml2js'), parser = new xml2js.Parser();
>        parser.addListener('end', function(result) {
>            var command = require(result['@']['action']);
>            var c = new command(socket);
>            c.run();
>        }).parseString(data);
>    });
> });
> server.listen('8081', '127.0.0.1');
>
>
> Good, but if i send many commands to server like this:
>
> telnet 127.0.0.1 8081
> <query action="some_action1"></query>
> <query action="some_action2"></query>
> <query action="some_action3"></query>
>
> My server is executing this action is asynchronous. How i can get
> running this actions is step by step ?
>
> --
> 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
>

-- 
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

Reply via email to