Recast  1
Game with custom magic
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
PlayersOnline.hpp
Go to the documentation of this file.
1 
12 #ifndef RECAST_SERVER_PLAYERSONLINE_H
13 #define RECAST_SERVER_PLAYERSONLINE_H
14 
15 #include <vector>
16 #include <string>
17 #include <unordered_map>
18 #include <mutex>
19 #include "io/SQLite.hpp"
20 #include "models/Player.hpp"
23 
24 const int SESSION_LENGTH = 128;
25 
27 public:
28  PlayersOnline(int playerCount) : maxPlayers(playerCount), currentPlayers(0) {};
29 
31 
32  std::vector<Player *> getOnlinePlayers() const;
33 
34  Player *getPlayerBySession(const std::string &session) const;
35 
46  std::string
47  authPlayer(std::string login, std::string password);
48 
54  void registerPlayer(std::string login, std::string password);
55 
62  bool logout(const std::string &session);
63 
64  int playersOnline() const { return currentPlayers; }
65 
66 private:
67  std::unordered_map<std::string, Player *> players;
68  mutable std::mutex lock_writing;
69  int maxPlayers;
70  volatile int currentPlayers;
71  SQLite sqLite;
72 };
73 
74 
75 #endif //RECAST_SERVER_PLAYERSONLINE_H
PlayersOnline(int playerCount)
Definition: PlayersOnline.hpp:28
Player file.
int playersOnline() const
Definition: PlayersOnline.hpp:64
Player * getPlayerBySession(const std::string &session) const
Definition: PlayersOnline.cpp:36
~PlayersOnline()
Definition: PlayersOnline.cpp:55
std::vector< Player * > getOnlinePlayers() const
Definition: PlayersOnline.cpp:46
bool logout(const std::string &session)
Definition: PlayersOnline.cpp:21
void registerPlayer(std::string login, std::string password)
Definition: PlayersOnline.cpp:63
const int SESSION_LENGTH
Definition: PlayersOnline.hpp:24
This class helps to easily put or get var from DB. Using sqlite_orm and sqlite.
Definition: SQLite.hpp:55
std::string authPlayer(std::string login, std::string password)
Definition: PlayersOnline.cpp:72
Definition: PlayersOnline.hpp:26
Player class. XP, Life points and other.
Definition: Player.hpp:19