Passing coordinates data with the connected users

Let's go ahead and do just that over inside server.js, registering a new event listener. I'm going to remove the old commented out broadcast call that's no longer needed in createMessage. Just below createMessage, we're going to call socket.on again, specifying a listener for this event, createLocationMessage, just as we defined it over inside index.js. Now we are using ES6 since we're in Node, which means we can go ahead and set up our arrow function. We're going to have one argument, this is going to be the coords, and we can go ahead and finish off the arrow function.

 socket.on('createMessage', (message, callback) => { console.log('createMessage', message); io.emit('newMessage', generateMessage(message.from, ...

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.