File: ServerInfo.cpp

package info (click to toggle)
eris 1.2.1-1
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 2,360 kB
  • ctags: 1,348
  • sloc: sh: 8,289; cpp: 7,576; perl: 287; ansic: 172; makefile: 143
file content (48 lines) | stat: -rw-r--r-- 881 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifdef HAVE_CONFIG_H
	#include "config.h"
#endif

#include <Eris/ServerInfo.h>

#include <Eris/Utils.h>
#include <Eris/Log.h>

#include <Atlas/Objects/Entity/RootEntity.h>

namespace Eris
{

ServerInfo::ServerInfo(const std::string &host) :
	_host(host)
{
	_ping = -1;
	_name = "-";
	_ruleset = "-";
	_server = "";
	_clients = 0;
	_uptime = 0;
}
	
void ServerInfo::processServer(const Atlas::Objects::Entity::RootEntity &svr)
{
try {
	_ruleset = svr.getAttr("ruleset").asString();
	_name = svr.getName();
	_clients = svr.getAttr("clients").asInt();
	_server = svr.getAttr("server").asString();
	_uptime = svr.getAttr("uptime").asFloat();
} catch (...)
    {
	std::string summary(objectSummary(svr));
	Eris::log(LOG_ERROR, 
	    "atlas exception parsing server INFO response: object looks like %s",
	    summary.c_str());
    }
}

void ServerInfo::setPing(int p)
{
	_ping = p;
}

}