Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

Implement socket.io in node.js application controller

//app.js or index.js
const app = express();
var http = require("http");
var server=http.createServer(app).listen(2525, (req, res) => {
  console.log("Server running on", 2525);
});
var socketIO = require("socket.io");
var io = socketIO(server);
global.io = io //Importent line

//Add the below statement to your controller code
global.io.emit("eventname", "yourdata"); //Importent line
Source by socket.io #
 
PREVIOUS NEXT
Tagged: #Implement #application #controller
ADD COMMENT
Topic
Name
6+6 =