Skip to content

Commit

Permalink
emit newmessage on create new msg
Browse files Browse the repository at this point in the history
  • Loading branch information
paras151 committed Aug 3, 2019
1 parent 0c2df3d commit ff17995
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ io.on('connection',(socket)=>{
socket.on("disconnect",()=>{
console.log("User was disconnected")
})
socket.emit('newMessage',{
from: "John",
text: "See you then",
createAt:"123"
});

socket.on('createMessage',(newMessage)=>{
console.log('createMessage',newMessage);

socket.on('createMessage',(message)=>{
console.log('createMessage',message);

io.emit('newMessage',{
from:message.from,
text:message.text,
createdAt:new Date().getTime()
})
})

})
Expand Down

0 comments on commit ff17995

Please sign in to comment.