Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

node.js real-time game

Tags:

node.js

Is it possible to create a real time game with node.js that requires twitch reflexes. How high is the latency? How low can it realistically go?

like image 733
Mark Avatar asked Apr 28 '10 00:04

Mark


1 Answers

It is possible to make a real-time game in node.js as you could with any other language/framework.

The problem here would be what kind of server and client you would use.
Using the http server feature for such game would be a bad idea and very difficult, but you could use the TCP server (now called net server) as you would in any other language.

The client would be on some platform where you can use sockets, like Flash, Java applets or desktop software.

Please notice that even with using a TCP socket server you might have problems with latency for a twitch game, but this is outside the area related to this question and more about games and networking.

PS: You could use web sockets since they should theoretically work like TCP sockets but there isn't yet a good support for them in the current modern browsers.


EDIT:

It seems I haven't explained myself correctly, you can make a browser accessible game like you said, you just need to use a protocol that allows you to quickly send data back and forth in real time.

If you want a "pure" browser game without any third party plugins the only way, like I said before, is using JavaScript with websockets which is not well supported yet by the major browsers. (You could use a Flash bridge and still have your game in JavaScript though.)

Using a third party plugin you have Flash and Java (besides the numerous less known plugins like unity and so on). Both have TCP sockets (not sure about UDP) and can be made to connect to a node.js net server (with some security limitations). Most people would say for you to go with Flash since there is a bigger support but Apple doesn't like it so no Flash in iPhone/iPad/iPod Touch or on other miscellaneous mobile devices (that support Java instead).

So yeah... good luck with this.

EDIT 2:

Websocket support in browsers is now pretty decent so I recommend it for realtime games if you want to use the browser as a client.

like image 57
Diogo Gomes Avatar answered Nov 10 '22 05:11

Diogo Gomes