docket io client code example
Example 1: socket.io reconnect example
io.connect('http://localhost', {
'reconnection': true,
'reconnectionDelay': 500,
'reconnectionAttempts': 10
});
Example 2: socket.io client send data node js server
var socket = io.connect('http://localhost');
socket.emit('my other event', { my: 'data' });
io.sockets.on('connection', function (socket) {
socket.on('my other event', function (data) {
console.log(data);
});
});
socket.on("test", function (data) {
data.forEach(obj => {
console.log("Yer : " + obj.yer + ", Lat : " + obj.lat + ", Long : " + obj.lng);
})
});