2

Possible Duplicate:
How to make a browser to browser (peer to peer) connection?

I'm planning on making a multiplayer game web game, and it would be awesome if it worked over lan (since it's faster and I want people, that play together, to sit in the same room.)

The idea is that each client is a webpage, one of them is the master, which all others connect to (the others don't have to communicate with each other.) Each client also is a webpage.

So now I was wondering, are there any javascript libraries out there that can do this? Connecting computers over lan, without the need of an internet connection (other than actually loading the webpage.)

I saw some older answers which didn't help much, so maybe there's something new that can help me?

Community
  • 1
  • 1
The Oddler
  • 6,314
  • 7
  • 51
  • 94
  • 1
    I don't think browser javascript exposes any functionality to create listening sockets. – lanzz Sep 16 '12 at 13:30
  • You'd still need an apache/similar server. – hjpotter92 Sep 16 '12 at 13:30
  • I have no idea about javascript libraries, but have you ever came across http://nodejs.org ?? –  Sep 16 '12 at 13:34
  • 4
    You still need a server, which you cannot setup in a browser. I think this question shows a severe lack of understanding of such technologies, and proceedings this way will likely result in a disappointing experience. Pick a project that is a little easier to get started and learn before building an in-browser javascript served MPORPG. – GolezTrol Sep 16 '12 at 13:38
  • I'm not building an rpg, much simpler. Something similar to Artemis (if you know it? It's awesome), though got an idea was that I build the ship (master client) and then everyone can make stations for it. And would be cool if people could just host their stuff in their dropbox folder or something. Unity can make lan stuff easy, so why shouldn't it be possible in html & javascript? – The Oddler Sep 16 '12 at 13:47
  • As I said in my answer, javascript CAN'T be a server. It is only a client-side interpreter with no access to files due to security. If you want to make a server, then you have to setup a web server in your lan host. Don't compare Javascript with Unity it has nothing to do. Unity is a game engine, Javascript is a programming language mostly for web purposes. – ngonzalvez Sep 16 '12 at 14:18
  • @Kryz — Please don't conflate "JavaScript" and "JavaScript running in a browser from the context of a webpage" – Quentin Sep 16 '12 at 14:22
  • Isn't that what is being asked over here? Or are we talking about setting up a nodejs server? I'm just saying that, as far as I know, client-side javascript alone can't handle lan connections. Am I wrong? – ngonzalvez Sep 16 '12 at 14:32
  • There is no difference between "LAN" and "Anywhere else on TCP/IP" as far as JS in a browser is concerned. (Different origins cause problems, but that has nothing to do with being on a LAN). – Quentin Sep 16 '12 at 14:47
  • @GolezTrol (& Kryz), I was just hoping people with a much better understanding of this technology made it easy for me to use, just like the people of Unity did it. – The Oddler Sep 16 '12 at 18:22
  • I believe you need a better understand of what is the Unity Web player and what is HTML5. – Alerty Sep 16 '12 at 19:54
  • I know what the Unity webplayer is, I wasn't talking about that. I meant that networking never is an easy thing to do, though the Unity people managed to make it pretty easy to use, so I was hoping something similar existed for html. I just didn't know about the limitations of html/js. – The Oddler Sep 16 '12 at 20:46

1 Answers1

1

Node.js could be really helpful in your case. You could also try to use HTML5 WebSocket API.

Community
  • 1
  • 1
Jan.J
  • 3,050
  • 1
  • 23
  • 33
  • I ran across node.js though I didn't think it could actually host a lan server from within the browser. Am I correct in thinking that? I'll try out one of their examples, though any more information about node to get me started is always appreciated :D Thanks! – The Oddler Sep 16 '12 at 13:54
  • 1
    @TheOddler — Yes, you are correct. It lets you run JS code outside a browser (typically to run a server). The host would have to download Node, and your JS software and then run the latter using the former. – Quentin Sep 16 '12 at 14:15
  • And is it then possible to connect from a game on a webpage to this server? If not, it won't have any advantage (for the idea I had) to any other networking solution. – The Oddler Sep 16 '12 at 18:11