Backend will emit this whenever an invalid input is received
Params to be received: String
Backend will emit this as a reply for inputUser.
Params to be received: [{_id, username, avatar, lat, long}]
Frontend can iterate over the users by using map as it is an array of objects. Example:
socket.on("outputUser", users => {
console.log(users.map(user => user.username))
})
Emitted by backend to frontend (all users) as a reply for inputMessage.
Params to be received: [{username, text}]
Emitted by backend to frontend (all users) as a reply for inputPosition.
Params to be received: [{_id, username, avatar, lat, long}]
Emitted by backend to frontend when someone disconnected.
Params to be received: id
id is the id (String) of the user that left
Emitted by backend to frontend (all users) when a user's data is changed (e.g. changing username/avatar).
Params to be received: [{_id, username, avatar, lat, lng}].
Automatically called when a user is initially connected (Done by socket.io)
Emitted by frontend to backend when the user entered a username and chose an avatar.
Params to be sent: {username, avatar, lat, long}
Example:
const newUser = {username: "john", avatar: "male1", lat: "3000", long: "40000"}
socket.emit("inputUser", newUser);
Emitted by frontend to backend when a user sent a message.
Params to be sent: {text}
Emitted by frontend to backend when a user moves to another location (For example, you might want to emit this event every 5 seconds)
Params to be sent: {lat, long}
Emitted by frontend to backend when a user updates its data.
Params to be sent: {username, avatar, lat, long}. All optional (no need to include all 4)