Answers for "socket.io on connection"

0

socket.io on connection

io.on('connection', (socket) =>{
   console.log(`Connecté au client ${socket.id}`)
})
Posted by: Guest on August-05-2021
2

socket io script

<script src="/socket.io/socket.io.js"></script>
<script>
  const socket = io();
</script>
Posted by: Guest on August-29-2020
1

js socket.emit

const socket = io('ws://localhost:3000');
socket.on('connect', () => {  
  // either with send()  
  socket.send('Hello!');
  // or with emit() and custom event names  
  socket.emit('salutations', 'Hello!', { 'mr': 'john' }, Uint8Array.from([1, 2, 3, 4]));});
// handle the event sent with socket.send()
socket.on('message', data => {
  console.log(data);
});
// handle the event sent with socket.emit()
socket.on('greetings', (elem1, elem2, elem3) => {
  console.log(elem1, elem2, elem3);
});
Posted by: Guest on September-21-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language