Let's go ahead and do that over inside Atom, we are going to call socket.emit and emit a brand new event, one we do not have registered yet. We're going to call this one createLocationMessage:
navigator.geolocation.getCurrentPosition(function (position) {
socket.emit('createLocationMessage', {
});
});
The createLocationMessage event is not going to take the standard text; instead, it's going to take those longitude and latitude coordinates. We're going to specify both of them starting with latitude; we want to set latitude equal to position.coords.latitude. This is the variable that we explored over inside of the console, and we're going to do the same thing for longitude, setting it equal to position.coords.longitude:
navigator.geolocation.getCurrentPosition(function (position) {
socket.emit('createLocationMessage', {
latitude: position.coords.latitude,
longitude: position.coords.longitude
});
Now that we have this in place we can actually go ahead and listen for this event over in the server, and when we get it what we're going to do is pass the above data along to all the connected users.