eris  1.4.0
A WorldForge client library.
ServerInfo.cpp
1 #include <utility>
2 
3 #ifdef HAVE_CONFIG_H
4  #include "config.h"
5 #endif
6 
7 #include "ServerInfo.h"
8 
9 #include "Log.h"
10 
11 #include <Atlas/Objects/Entity.h>
12 
13 
14 using Atlas::Objects::Entity::RootEntity;
15 
16 namespace Eris
17 {
18 
19 void ServerInfo::processServer(const RootEntity &svr)
20 {
21  Atlas::Message::Element element;
22 
23  if (!svr->copyAttr("ruleset", element) && element.isString()) {
24  ruleset = element.String();
25  } else {
26  return;
27  }
28 
29  name = svr->getName();
30  if (!svr->copyAttr("clients", element) && element.isInt()) {
31  clients = (int)element.Int();
32  } else {
33  return;
34  }
35  if (!svr->copyAttr("server", element) && element.isString()) {
36  server = element.String();
37  } else {
38  return;
39  }
40  if (!svr->copyAttr("uptime", element) && element.isFloat()) {
41  uptime = element.Float();
42  } else {
43  return;
44  }
45 
46  status = VALID;
47 
48  if (!svr->copyAttr("entities", element) && element.isInt()) {
49  entities = element.Int();
50  }
51 
52  if (!svr->copyAttr("version", element) && element.isString()) {
53  version = element.String();
54  }
55 
56  if (!svr->copyAttr("builddate", element) && element.isString()) {
57  buildDate = element.String();
58  }
59 
60  if (!svr->copyAttr("protocol_version", element) && element.isInt()) {
61  protocol_version = element.Int();
62  }
63 
64  if (!svr->copyAttr("assets", element) && element.isList()) {
65  for (auto& url : element.List()) {
66  if (url.isString()) {
67  assets.emplace_back(url.String());
68  }
69  }
70  }
71 
72 }
73 
74 } // of namespace Eris
int clients
the number of clients currently connected to the server
Definition: ServerInfo.h:56
long protocol_version
version of the protocol used
Definition: ServerInfo.h:53
long entities
the number of entities on the server
Definition: ServerInfo.h:62
std::string server
the server program name, i.e &#39;stage&#39; or &#39;cyphesis&#39;
Definition: ServerInfo.h:51
std::string buildDate
the server program build-date, as a free text string
Definition: ServerInfo.h:70
Definition: Account.cpp:33
std::string name
retrieve the human-readable name of the server (e.g &#39;Bob&#39;s Mason Server&#39;)
Definition: ServerInfo.h:47
double uptime
the server&#39;s uptime in seconds
Definition: ServerInfo.h:65
std::string ruleset
retrieve a human-readable name of the ruleset (e.g. &#39;mason&#39; or &#39;circe&#39;)
Definition: ServerInfo.h:49
void processServer(const Atlas::Objects::Entity::RootEntity &svr)
Definition: ServerInfo.cpp:19
std::vector< std::string > assets
Definition: ServerInfo.h:75
std::string version
the server program version, as a free text string
Definition: ServerInfo.h:68