Answer the question
In order to leave comments, you need to log in
How to send message through socket.io outside of io.sockets.on('connection', function (client)?
there is an index.js file
in it, I listen to events from the asterisk, I use Nami.
var nami = new namiLib.Nami(namiConfig);
....
nami.on('namiEvent', function (event) {
//вот тут надо отправить сообщение о событии
})
io = require('socket.io');
....
io.sockets.on('connection', function (client) {
client.on('adduser', function (message) {
...
});
}
Answer the question
In order to leave comments, you need to log in
var nami = new namiLib.Nami(namiConfig),
io = require('socket.io'),
clients = [];
nami.on('namiEvent', function (event) {
clients.forEach(function(client) {
client. // делаем что нужно с каждыйм клиентом
// или фильтруем массив или выбираем одного
});
})
io.sockets.on('connection', function (client) {
client.on('adduser', function (message) {
clients.push(client);
});
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question