Skip to content

Instantly share code, notes, and snippets.

@YuriFontella
Created September 10, 2018 16:18
Show Gist options
  • Save YuriFontella/45f8ac73a162afe79ad5740ecd19b7c8 to your computer and use it in GitHub Desktop.
Save YuriFontella/45f8ac73a162afe79ad5740ecd19b7c8 to your computer and use it in GitHub Desktop.
listen redis channels
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