node.js - Browsers not updating when sockets get emmited -


I am trying to create a chat system here:

The top field takes the name of the user while the tetherera receives the message below. Once the user is pressed, the middle textara (which is inactive) is recorded, then it is updated with the new record. This is done using nodes JS Sockets. My problem is that if I open another example of Google Chrome and I do not update some other types of Google Chrome texts, then this case should be covered in my code because I am surprised:

< P> Here is the server.as code that inserts. After inserting it, it emits the socket with the final entry so that the index can be updated automatically.

  io.sockets.on ("connection", function (socket) {on socket ("send", function (data) {mongodb.connect ("mongodb: //127.0.0.1: 27017 / myDatabase ", function (mistake, db) {throwing {if}; var to_be_inserted = {name: data .name, content: data.content} db.collection (" chat "). Insert (to_be_inserted, function (Mistake, objects) {if throws (mistake); var cursor = db.collection ("chat"). () .sort ({_ id: -1}) border (1); cursor tuare (function (error , Document) {console.log ("abc"); socket.emit ("data_to_be_printed", docs);})}}}}}}}})  

})

Once you can insert data , The socket is emitted with the last line of DB index.html This socket should be handled by updating itself. Here is the code that handles it:

  

  

Comments