Skip to content

Commit

Permalink
Merge pull request github#1 from feliperosademendonca/reativar-envio-…
Browse files Browse the repository at this point in the history
…e-sincronização-do-chat

Reativar envio e sincronização do chat
  • Loading branch information
feliperosademendonca authored Oct 12, 2022
2 parents 4ba2dbb + c52d991 commit 32e2d18
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 19 deletions.
1 change: 0 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<link rel="shortcut icon" href="img/favicon.icon" type="image/x-icon">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.2/socket.io.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>


<script type="text/javascript" src="scripts/popUp.js"></script>
Expand Down
9 changes: 7 additions & 2 deletions public/scripts/message.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ var socket = io ('http://localhost:5000');


function renderMessage(message){

if(message.id== "usuario"){

if(message.id== "usuario"){
alert(message.id)

$('<div class="enviada"><strong>'+message.author+'</strong>:'+message.message +"<br>").appendTo('#chat');
var audio = new Audio('./fx/tik.mp3');

audio.play();

}else{
alert("recebida")

$('<div class="recebida"><strong>'+message.author+'</strong>:'+message.message +"<br>").appendTo('#chat');
var audio = new Audio('./fx/won.mp3');
audio.play();
Expand All @@ -28,6 +32,7 @@ var socket = io ('http://localhost:5000');
socket.on('previousMessage', function(messages){
for (message of messages)
renderMessage(message);

});

//comunicação com todos os conectados
Expand Down
13 changes: 4 additions & 9 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -30,12 +29,8 @@ io.on('connection', socket => {
});

});

const PORT = process.env.PORT|| 5000;

app.listen(PORT, () =>{
console.log("listening on port "+PORT);
})

console.log(messages)

server.listen(5000)


9 changes: 2 additions & 7 deletions tarefas.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
ajustar a barra de rolagem lateral


Função desabilitar sons

ok alertar que precisa ter um nickname para conversar no chat

<<<<<<< Updated upstream
ok! subir para o heroku para testar em uma hospedagem free
=======
ok subir para o heroku para testar em uma hospedagem free (chat não funciona)
>>>>>>> Stashed changes
subir para o heroku para testar em uma hospedagem free (chat não funciona)

ok! sons do whatsapp ou parecidos

ok! Configurar node e as rotas
Expand Down

0 comments on commit 32e2d18

Please sign in to comment.