points[row.time_update] = [ {val1: 1, val2: 123, val6:321}, {val1: 21, val2: 777, val6:2} ... ]
socket.on('update_recv', function(data) {
console.log(data);
});
socket.on('update', function(data){
knex(sql .... ).then(function(rows){
// processed line, collect the points array in the required format.
var keys = Object.keys(points); // need to issue a batch by date
for( var k in keys )
{
// here begins my unknown magic. If bryaknut after socket.emit
// the data arrives. ie 1 time. otherwise, the cycle goes on, but the front
// nothing comes.
socket.emit('update_recv', {result: JSON.stringify(points[keys[k]]) })
sleep.sleep(3); // need delay until the rough
}
});
});
Find more questions by tags Socket.ioJavaScript
For a start, even as a string you can remove the json to send the numbers, separated by commas, - mercedes commented on July 9th 19 at 10:52
An example of what is to come
{ latitdue: '22.314567',
longitude: '39.105341',
mac_id: '3A14',
battery_level: 68 },
{ latitdue: '22.314935',
longitude: '39.097595',
mac_id: '872',
battery_level: 72 },
{ latitdue: '22.314935',
longitude: '39.097595',
mac_id: '872',
battery_level: 72 } - Ambros commented on July 9th 19 at 11:04
i.e. when:
for(var k in keys){
console.log(k);
socket.emit('node_update_recv2', {result: k});
sleep.sleep(3);
}
the console prints k consistently right and to the front came just a 0, without 1,2,3... ie socket.emit() is executed once - Ambros commented on July 9th 19 at 11:13