Answers for "socket io"

2

install socket.io

npm i socket.io
Posted by: Guest on October-03-2020
2

socket io

const server = require('http').createServer();
const io = require('socket.io')(server);
io.on('connection', client => {
  client.on('event', data => { /* … */ });
  client.on('disconnect', () => { /* … */ });
});
server.listen(3000);
Posted by: Guest on March-23-2021
1

socket io

It is a library that enables real-time, bidirectional and event-based communication between the browser and the server.
Posted by: Guest on July-03-2021
2

socket io

npm install --save socket.io
Posted by: Guest on December-01-2019
0

socket io

npm install socket.io
Posted by: Guest on December-02-2020
0

socket io

//Importamos la app
const app = require('./app');

const socketIO = require('socket.io');

//Con el modulo 'dotenv' importamos las variables de entorno
//contenidas dentro del archivo '.env'
//Se recomienda correr este proyecto con permisos de administrador
require('dotenv').config();

//Importamos la conexion a la base de datos dentro de 'database.js'
require('./database/database');

//Esta funcion ejecuta el servidor
async function main(){


    //Obtenemos el puerto
    const PORT = app.get('port');  

    //Escuchamos el servidor en puerto y con '0.0.0.0' podemos acceder publicamente
    server = await app.listen(PORT, '0.0.0.0');

    
    const io=socketIO.listen(server);

    //console.log('io index: ', io)

    /*
    io.on('connection', function(){
        console.log('Socket Conectado');
        io.emit('Prueba', 'Hola soy el servidor'.toString());
    });
    */
    
    
    //Mostramos por consola
    console.log('Servidor ejecutandose en el puerto: ', PORT);

> };

main();
Posted by: Guest on September-10-2021

Browse Popular Code Answers by Language