#SocketIO

1 messages · Page 1 of 1 (latest)

hushed locust
#

Escribime por aca, asi no explotamos tanto el chat del ds

#

Me podes pasar el codigo que tenes ahora?

zenith summit
#

ok

hushed locust
#

SocketIO

zenith summit
#
const http = require("http");
const socketio = require("socket.io");

const app = express();
const httpServer = http.createServer(app);
const io = new socketio.Server(httpServer);

io.on('connection', () => {
    console.log('new user');
});


app.use(express.static('public'));


app.listen(3000, () => {
    console.log('server on port 3000');
});

hushed locust
#

en vez de app.listen, pone httpServer.listen

zenith summit
#

sigue sin funcionar bro

hushed locust
zenith summit
#

?

#

no se que frontend

#

ahi lo busco

hushed locust
#

en la pagina web, estas usando socket.io tambien, no?

zenith summit
#
const http = require("http");
const socketio = require("socket.io");

const app = express();
const httpServer = http.createServer(app);
const io = new socketio.Server(httpServer);

io.on('connection', () => {
    console.log('new user');
});


app.use(express.static('public'));


httpServer.listen(3000, () => {
    console.log('server on port 3000');
});

Hací estoy usando el codigo

hushed locust
#

nono, me refiero en la pagina web, en el frontend

zenith summit
#

?

hushed locust
#

no tenes un html en la carpeta public?

zenith summit
#

Si

hushed locust
#

tenes un archivo javascript vinculado a ese HTML?

zenith summit
#
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/css/main.css">
    <title>chatkk</title>
</head>
<body>
    <script src="/js/main.js"></script>
    
    <h1>Codigoo</h1>
</body>
</html>

hushed locust
#

me podes mostrar ese archivo o el script?

zenith summit
#

ahí te lo pase

#

no se si te llego

hushed locust
#

No llego

zenith summit
#
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="/css/main.css">
    <title>chatkk</title>
</head>
<body>
    <script src="/js/main.js"></script>
    
    <h1>Codigoo</h1>
</body>
</html>
#

perdon

hushed locust
#

nono, me refiero al archivo js, el main.js

zenith summit
#

ohh

#

ahi te lo mando

#
CSS
body{
    background: #009FFF;  /* fallback for old browsers */
background: -webkit-linear-gradient(to right, #ec2F4B, #009FFF);  /* Chrome 10-25, Safari 5.1-6 */
background: linear-gradient(to right, #ec2F4B, #009FFF); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */

}

JS
alert("XD");
#

Si no, buscaré otra forma de hacer el front end

hushed locust
#

Busca un video mas actualizado para hacer el chat por socket io, en el frontend, o en tu pagina web deberias tener la libreria de socketio

#

y desde ahi hacer la conexion al servidor

zenith summit
#

ok