How to maintain player connections.

Options
Hello. I have a question. I want to maintain a list of connections for all players. I might add, remove, or retrieve a player's connection to this list. For example, when a player goes online, I need to add his connection to the list, and when the player drops, I need to remove the connection. Can you give me a suggestion on what data structures to use to maintain this list. List or Dictionary. Do I need to focus on multithreaded access. Do I need to use thread locks.

Comments

  • ExitVip
    Options
    Can someone give me some advice
  • ExitVip
    Options
    @Kaiserludi admin
  • BesoC
    BesoC ✭✭
    Options
    We are using ConcurrentDictionary for this purpose. Please note that you should not use Peer's ConnectionId property as a key, because it is not guaranteed to be unique,
  • chvetsov
    Options
    @ExitVip sure you have to use locks or some thread safe collection

    best,
    ilya