-1

Possible Duplicate:
Can't find socket.io.js

Well when using socket.io you need to include the client side using

<script type="text/javascript" src="socket.io/socket.io.js"></script>

But where do I find the "socket.io.js" I need to put into the /socket.io/ folder for the clients?

Community
  • 1
  • 1
Wingblade
  • 9,585
  • 10
  • 35
  • 48

2 Answers2

1

https://github.com/LearnBoost/socket.io-client - more information on the best practice for serving the socket.io client js file can be found here: https://github.com/LearnBoost/Socket.IO/wiki/How-do-I-serve-the-client

Dan Smith
  • 5,685
  • 32
  • 33
  • This is what I was searching for, thank you. – Wingblade Jul 13 '12 at 09:27
  • @Wingblade note that socket.io auto-generates this js file for you, hence you shouldn't need to download it to include it in your projects (just link to http://yournodeserver:nodeport/socket.io/socket.io.js) – Mahn Oct 28 '13 at 16:52
-1

The socket.io.js file is generated and offered by the server, hence there's no need to provide it yourself.

If you're using jQuery, you can use the following snippet to get the file

$.getScript('http://localhost:1337/socket.io/socket.io.js', function(){
    //You can now use the io namespace
});

I struggeled with this myself and have posted a question about it earlier on SO.

Community
  • 1
  • 1
thomaux
  • 19,133
  • 10
  • 76
  • 103
  • He meant, "where do I go on the Internet to download the file". – Pointy Jul 12 '12 at 11:42
  • @Pointy, no he did not. There's no such thing as a socket.io.js that you can include at client side. – thomaux Jul 12 '12 at 11:43
  • I did, I meant where on the internet, also there is something that has to be included on clientside. How else would the client know the functions of socket.io, like socket.on and so on? – Wingblade Jul 12 '12 at 11:44
  • @ValentinKrummenacher, you need to include it like in my answer, there's no file to be placed somewhere in a scripts folder. – thomaux Jul 12 '12 at 11:47
  • So instead of http://localhost:1337 I put the IP of my nodejs server? Or of the webserver the html and javascript files of my game are hosted? – Wingblade Jul 12 '12 at 11:52
  • Yes indeed, you need to replace it with the IP to your nodeserver. – thomaux Jul 12 '12 at 11:53
  • 1
    There is in fact a javascript file you can include - although they do recommend this method. See this page: https://github.com/LearnBoost/Socket.IO/wiki/How-do-I-serve-the-client – Dan Smith Jul 12 '12 at 12:16