#SocketIO
1 messages · Page 1 of 1 (latest)
Escribime por aca, asi no explotamos tanto el chat del ds
Me podes pasar el codigo que tenes ahora?
ok
SocketIO
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');
});
en vez de app.listen, pone httpServer.listen
sigue sin funcionar bro
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
nono, me refiero en la pagina web, en el frontend
?
no tenes un html en la carpeta public?
Si
tenes un archivo javascript vinculado a ese HTML?
<!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>
me podes mostrar ese archivo o el script?
No llego
<!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
nono, me refiero al archivo js, el main.js
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
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
ok