From cc2aa67a4216ff28882aa40ace7a33407ef4df63 Mon Sep 17 00:00:00 2001 From: felipe <107950074+feliperosademendonca@users.noreply.github.com> Date: Tue, 11 Oct 2022 15:20:24 -0300 Subject: [PATCH 1/2] reativando sinc chat --- server.js | 8 ++------ tarefas.md | 3 +-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/server.js b/server.js index 01f8d34de163..8cf43e8cf2c1 100644 --- a/server.js +++ b/server.js @@ -31,11 +31,7 @@ io.on('connection', socket => { }); -const PORT = process.env.PORT|| 5000; - -app.listen(PORT, () =>{ - console.log("listening on port "+PORT); -}) - + +app.listen(5000) \ No newline at end of file diff --git a/tarefas.md b/tarefas.md index e1b65818cec5..71f1bc73cb1b 100644 --- a/tarefas.md +++ b/tarefas.md @@ -1,11 +1,10 @@ ajustar a barra de rolagem lateral - Função desabilitar sons alertar que precisa ter um nickname para conversar no chat -ok! subir para o heroku para testar em uma hospedagem free +subir para o heroku para testar em uma hospedagem free (chat não funciona) ok! sons do whatsapp ou parecidos From 9c9554ee56afc301509025a488a587277f91d817 Mon Sep 17 00:00:00 2001 From: felipe <107950074+feliperosademendonca@users.noreply.github.com> Date: Tue, 11 Oct 2022 17:12:06 -0300 Subject: [PATCH 2/2] corrigido o app.listen para server.listen --- public/index.html | 1 - public/scripts/message.js | 9 +++++++-- server.js | 7 +++---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/public/index.html b/public/index.html index 288cf3034076..625d1deaf960 100644 --- a/public/index.html +++ b/public/index.html @@ -8,7 +8,6 @@ - diff --git a/public/scripts/message.js b/public/scripts/message.js index 6594a2b4b275..59da9db6a300 100644 --- a/public/scripts/message.js +++ b/public/scripts/message.js @@ -4,13 +4,17 @@ var socket = io ('http://localhost:5000'); function renderMessage(message){ - - if(message.id== "usuario"){ + + if(message.id== "usuario"){ + alert(message.id) + $('
'+message.author+':'+message.message +"
").appendTo('#chat'); var audio = new Audio('./fx/tik.mp3'); audio.play(); }else{ + alert("recebida") + $('
'+message.author+':'+message.message +"
").appendTo('#chat'); var audio = new Audio('./fx/won.mp3'); audio.play(); @@ -27,6 +31,7 @@ var socket = io ('http://localhost:5000'); socket.on('previousMessage', function(messages){ for (message of messages) renderMessage(message); + }); //comunicação com todos os conectados diff --git a/server.js b/server.js index 8cf43e8cf2c1..09e52b940a4f 100644 --- a/server.js +++ b/server.js @@ -20,8 +20,7 @@ let messages= []; io.on('connection', socket => { console.log(`Socket conectado: ${socket.id}`); - - socket.emit('previousMessage', messages); + socket.emit('previousMessage', messages); socket.on('sendMessage', data =>{ data.id= "historico" @@ -30,8 +29,8 @@ io.on('connection', socket => { }); }); - +console.log(messages) -app.listen(5000) +server.listen(5000) \ No newline at end of file