Skip to main content

Posts

Showing posts with the label Socket.io

How to implement Real time notification in NodeJs

Here are simple steps to create real time notification using NodeJs, Socket.io and Mysql Socket.IO enables real-time bidirectional event-based communication.It has two parts: a client-side library that runs in the browser, and a server-side library for node.js. Install Socket.IO npm install --save socket.io I hope you have install express and mysql. This are basic few code inside server file. var express = require( 'express' ); var app = express(); app.use( express.static( __dirname + '/public') ); var mysql = require('mysql'); var server = require( 'http' ).Server( app ); var io = require( 'socket.io' )( server ); server.listen( 3000, function(){   console.log( 'listening on *:3000' ); } ); app.get('/', function(req, res) {    res.sendFile(__dirname + '/index.html'); }); The require('socket.io')(http) creates a new socket.io instance attached to the http server. Now make mysql conn...