YAPOG  0.0.1
Yet Another Pokemon Online Game
ClientManager.cpp
Go to the documentation of this file.
2 
5 
6 namespace yse
7 {
9  yap::Time (0.05f);
10 
12  : clients_ ()
13  , clientsMutex_ ()
14  , receptionThread_ ([this] () { HandleReception (); })
16  {
17  }
18 
20  {
21  for (ClientSession* client : clients_)
22  delete client;
23  }
24 
26  {
27  {
28  yap::Lock lock (clientsMutex_);
29  clients_.Add (client);
30  }
31  }
32 
34  {
35  {
36  yap::Lock lock (clientsMutex_);
37  clients_.Remove (client);
38  }
39  }
40 
42  {
43  receptionIsActive_ = true;
45  }
46 
48  {
49  {
50  yap::Lock lock (clientsMutex_);
51 
52  for (ClientSession* client : clients_)
53  client->Refresh ();
54  }
55  }
56 
58  {
59  receptionIsActive_ = false;
60  }
61 
63  {
64  {
65  yap::Lock lock (clientsMutex_);
66 
67  for (ClientSession* client : clients_)
68  client->ServerTick (dt);
69  }
70  }
71 
73  {
74  while (receptionIsActive_)
75  {
77 
78  {
79  yap::Lock lock (clientsMutex_);
80 
81  for (ClientSession* client : clients_)
82  client->HandleReception ();
83  }
84  }
85  }
86 } // namespace yse