Posts

Showing posts with the label nodejs

Realtime Chat Application with CakePHP and Socket.IO #3

Image
In this tutoriel we are going to setup the nodejs server to recive socket.io events. First make sure that nodejs is correctly installed on your server in my case it was Debian Server Create a folder in your server and with commande line (pointed to this folder ) type npm init this create a file called package.json  we need this file to install ou node module to install just type npm install Modules Socket.IO : to be able to use realtime events in our application Node-mysql : to connect to mysql database nodemon :  this just dev dependency to restart the server when make (server side) changes we need to create another important file whitch is server.js this is the main server code in this file we are setup a nodejs / socket.io server and listen to it in port 3000 the server point to index.php file but you can point it to empty html file , it's not a problem NB: it's just requiring module , installed / or nativly included in nodejs li...

Socket.IO & Realtime application

Image
We all once believed that the development of a realtime application is difficult . But that's worng in fact it's not that difficult especialy for web developer the Reaseon ?  Socket.IO     To simplify things Socket.io is nodejs module (server side JavaScript)  to send and receive a kind of  events . Basically, you send and listen to emit events on both side front and back end   To install it on your project npm install socket.io you need also to include javascript library in the front end <script src="/socket.io/socket.io.js"></script><script> exemple  Client side : socket.on means we listen to an event called news socket.emit we send an event called my other event to the server Server Side : io.on('connection' is listen to when the user is connected when logged or not i takes socket as parametre socket conatins all connected users socket.emit send ...