socket io script
<script src="/socket.io/socket.io.js"></script>
<script>
const socket = io();
</script>
socket io script
<script src="/socket.io/socket.io.js"></script>
<script>
const socket = io();
</script>
import socket io frontend
<script src="/socket.io/socket.io.js"></script><script> const socket = io('http://localhost');</script>
socket..io
<script src="https://cdn.socket.io/socket.io-3.0.1.min.js"></script>
socket io
It is a library that enables real-time, bidirectional and event-based communication between the browser and the server.
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();
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us