Answer the question
In order to leave comments, you need to log in
Need help with socket.io?
Wrote a server side script:
var fs = require('fs'),
options = {
key: fs.readFileSync('/etc/letsencrypt/live/*******/privkey.pem'),
cert: fs.readFileSync('/etc/letsencrypt/live/*******/fullchain.pem')
},
app = require('express')(),
server = require('https').createServer(options, app),
io = require('socket.io')(server),
Redis = require('ioredis'),
redis = new Redis();
function log(log) { console.log('[APP] ' + log) }
redis.psubscribe('*', function(error, count){
});
redis.on('pmessage', function(pattern, channel, message){
message = JSON.parse(message);
io.emit(channel + ':' + message.event, message.data.message);
// console.log(channel, message)
});
server.listen(8443);
log('Локальный сервер запущен на порте ' + 8443);
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/3.0.3/socket.io.js" ></script>
<script>
var socket = io(':8443');
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question