Setting up acknowledgements

Setting up acknowledgments really isn't that bad if you already have a listener in place. All you have to do is make a quick change to the listener and a quick change to the emitter, and everything will work as expected.

Now in this case, the listener happens to be on the server and the emitter is going to be on the client, but acknowledgments also work in the other direction. I can emit an event from the server and I can acknowledge it from the client.

In order to set this up we are going to emit a createMessage event over inside index.js using socket.emit, and we're going to pass in the same arguments we would otherwise. The first one is the event name, createMessage, and we're going to pass in some valid data, ...

Get Advanced Node.js Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.