Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is the socket.io client library?

As far as I have seen, there is no explanation as to where we are to locate the client side script for socket.io if node.js is not used as the web server. I've found a whole directory of client side files, but I need them in a combined version (like it's served when using node.js webs servers). Any ideas?

like image 802
Braun Shedd Avatar asked Dec 16 '11 01:12

Braun Shedd


People also ask

How do I know if socket IO client is connected?

You can check the socket. connected property: var socket = io. connect(); console.

Is Socket.IO a library or framework?

Socket.IO is a library that enables low-latency, bidirectional and event-based communication between a client and a server. It is built on top of the WebSocket protocol and provides additional guarantees like fallback to HTTP long-polling or automatic reconnection.

Is Socket.IO JavaScript library?

Socket.IO is composed of two parts: A server that integrates with (or mounts on) the Node. JS HTTP Server socket.io. A client library that loads on the browser side socket.


2 Answers

The best way I have found to do this is to use bower.

bower install socket.io-client --save 

and include the following in your app's HTML:

<script src="/bower_components/socket.io-client/socket.io.js"></script> 

That way you can treat the socket.io part of your client the same way you treat any other managed package.

like image 113
Matt Way Avatar answered Oct 12 '22 23:10

Matt Way


socket.io.js is what you're going to put into your client-side html. Something like:

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

my script is located:

/usr/local/lib/node_modules/socket.io/node_modules/socket.io-client/dist/socket.io.js 

copy that file to where you want your server to serve it.

like image 31
EhevuTov Avatar answered Oct 12 '22 21:10

EhevuTov