![Call socket event from router page in Node Call socket event from router page in Node](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSdGL0879DKW-TRZG2OPzX_XW6_MbBTYQGFCTF2x33V-59IKifZurYPr9St2iix8C8ryMzeMAy4BvBBu59ecTvQ6JWnwtcKBQdFk7RpvwZ4MUlechi8ZEx6PtxI_lC9rOuzmvcPcZj0DR_/d/Call+socket+event+from+router+page+in+Node.png)
Question: How to send socket notification from Node API/Router?
-
In App file (like index.js OR app.js)
//Express setup var express = require('express'); var app = express(); //socketsetup setup var io = require('socket.io')(https); app.set('io', io); //IMP this will let available io in router file
-
In Router or Controller file
exports.sendnotify = function(req, res) { var io = req.app.get('io'); io.sockets["in"]('room_446').emit('session_end_notify', {vid:100,event_type:'live'}); //Send the Notification res.send('node is working fine'); };
Question: How decrypt a text which is encoded with base64?
let buff = Buffer.from('ENCRYPTED_TXT', 'base64'); print buff.toString('ascii');