I am making a game here. It will be free and I am choosing nodejs as it's
server.
I am not very new with Javascript. I've coded some easy client side
Javascript for about 1.5 years but server side coding with javascript sure
is very different from the client side.
so I have to learn more about it.
While making this game I realized that JavaScript performence isn't enough.
Perhaps it's just this laptop of mine is 6 years old but I do think that
it's still to slow.
A pathfinding algorithm might take 100ms each and in this game The path
finding algorithm require to be called around 50 times every second. so I
think I will connect JavaScript with C++ program trough child_process. I
first think exec will do the job but it doesn't have stdin so I use spawn.
I made a sample for something easy.
The code in C++ just infinites loop and keep asking input in integers and
outputs double of it.
(e.g. 50 outputs 100 )
and write a proxy code between nodejs and C++
var doubleIt = (function(){
>
> var Program = spawn('easy2.exe');
>
> var callOnOutput = function( output ){}
>
> Program.stdout.on('data', function( data ){
>
> callOnOutput( data.toString() );
>
> });
>
> Program.stderr.on('data', function( data ){
>
> console.log( "Error : " + data );
>
> throw new Error( data );
>
> });
>
> return function( input, callback ){
>
> callOnOutput = function( output ){
>
> callback( output );
>
> }
>
> Program.stdin.write( input + '\n' );
>
> }
>
> })();
>
>
This code works outputs correctly
doubleIt( 50, console.log );
outputs 100 on console
but the program won't exit after all the callback is called
something is wrong
can anyone help me ?
--
--
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.