Created
September 10, 2018 16:18
-
-
Save YuriFontella/45f8ac73a162afe79ad5740ecd19b7c8 to your computer and use it in GitHub Desktop.
listen redis channels
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = require('express')() | |
const server = require('http').Server(app) | |
const io = require('socket.io')(server) | |
const redis = require('redis') | |
server.listen(8890) | |
io.on('connection', function (socket) { | |
const connection = redis.createClient(6379, '192.168.0.100') | |
connection.subscribe('logs') | |
connection.on('message', function (channel, message) { | |
socket.emit(channel, message) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment