delaford / game

⚔️ An online JavaScript 2D Medieval RPG.
https://play.delaford.com/?useGuestAccount
MIT License
1.36k stars 880 forks source link

Chat message should only appear for user's who are "close" to hear it #27

Open djasnowski opened 6 years ago

djasnowski commented 6 years ago

Do you want to request a feature or report a bug?

bug

What is the current behavior?

When a user types on chat, everyone in the map can see it.

If the current behavior is a bug, please provide the exact steps to reproduce.

What is the expected behavior?

Player 2 should only see a message from the player who is saying a message if they are theoretically in their viewport. So 15x11 tiles should be their chat range.

djasnowski commented 5 years ago

It seems like a re-work of the Socket class is in order. We can extend this to the Player class so that way we don't need to statically call it and already have some vital information (like player's socket ID, x, y, etc.)

For example, player.emit to send back to only player's client and player.broadcast to send to all (in viewport).

The socket_id will really help de-clutter the current Socket.emit method that we currently do at the moment. Because right now it's like:

Socket.emit('CHAT:MESSAGE', {
  data: { type: 'normal', text: data.item.examine },
  player: {
    socket_id: this.player.socket_id,
  },
});

And then every time we do Socket.broadcast, to only have to broadcasted to those in the viewport. Because we are not going really broadcast to every single player.

erickcelio commented 4 years ago

I can work on that?

Ankaa19 commented 3 weeks ago

Hello, I would like to work on this issue. Could you assign me? Than you a lot.

david671-del commented 2 weeks ago

To ensure only "close" users receive chat messages, consider implementing a geo-targeting feature. This will allow you to display relevant content, such as "budget truck rentals near me," only to users in your vicinity. You can also provide a direct link for convenience: [budget truck rentals near me]](https://pickuprenttruckuae.com/)

david671-del commented 2 weeks ago

To ensure chat messages appear only for users who are "close," implement a geo-targeting feature. This way, you can display relevant content like "budget truck rentals near me." Check out more at [budget truck rentals near me(https://pickuprentuae.com/)