socket.io client send data node js server
var socket = io.connect('http://localhost');
socket.emit('my other event', { my: 'data' });
//server side
io.sockets.on('connection', function (socket) {
socket.on('my other event', function (data) {
console.log(data);
});
});
//sending data from the user via a socket.io
socket.on("test", function (data) {
data.forEach(obj => {
console.log("Yer : " + obj.yer + ", Lat : " + obj.lat + ", Long : " + obj.lng);
})
});<script src="/socket.io/socket.io.js"></script>
<script>
const socket = io();
</script>const socket = new WebSocket('ws://localhost:3000');socket.onopen(() => { socket.send('Hello!');});socket.onmessage(data => { console.log(data);});
Also in JavaScript:
- submitting login and sign up forms using AJAX
- js kill process
- reusable table in react js
- reduce function javascript
- convert string to datetime javascript
- await on observable
- puppeteer js onblur
- get value onChange from mat-select angular
- javascript console input
- date object javascript
- shorthand if in javascript with return
- jquery function return
- loopback find or create
- check for balanced parentheses in javascript
- angular bind to class or ngClass
- how to create duplicate key array in javascript
- using multiparty with node js express
- jquery get each row in table
- jquery table header agnostic of scroll
- regex for number and letters
- how to get value of button that click on it jquery
- javascript is number an integer
- promise catch
- js null is object typeof