eris 1.4.0
A WorldForge client library.
Person.cpp
1#ifdef HAVE_CONFIG_H
2 #include "config.h"
3#endif
4
5#include "Person.h"
6#include "LogStream.h"
7#include "Exceptions.h"
8#include "Lobby.h"
9#include "Connection.h"
10#include "Account.h"
11
12#include <Atlas/Objects/Entity.h>
13#include <Atlas/Objects/Anonymous.h>
14#include <Atlas/Objects/Operation.h>
15
16typedef Atlas::Objects::Entity::Account AtlasAccount;
17using namespace Atlas::Objects::Operation;
18using Atlas::Objects::Entity::Anonymous;
19using Atlas::Objects::Root;
20
21namespace Eris
22{
23
24Person::Person(Lobby &l, const AtlasAccount &acc) :
25 m_id(acc->getId()),
26 m_fullName(acc->getName()),
27 m_lobby(l)
28{
29
30}
31
32void Person::sight(const AtlasAccount &acc)
33{
34 if (acc->getId() != m_id)
35 {
36 error() << "person got sight(account) with mismatching Ids";
37 return;
38 }
39
40 if (acc->isDefaultName()) {
42 } else {
43 m_fullName = acc->getName();
44 }
45}
46
47void Person::msg(const std::string &msg)
48{
50 {
51 error() << "sending private chat, but connection is down";
52 return;
53 }
54
55 Anonymous speech;
56 speech->setAttr("say",msg);
57
58 Talk t;
59 t->setArgs1(speech);
60 t->setTo(m_id);
61 t->setFrom(m_lobby.getAccount().getId());
62 t->setSerialno(getNewSerialno());
63
65}
66
67} // of namespace Eris
const std::string & getId() const
returns the account ID if logged in
Definition: Account.h:325
bool isConnected() const
Ascertain whether or not the connection is usable for transport.
virtual void send(const Atlas::Objects::Root &obj)
Transmit an Atlas::Objects instance to the server.
Definition: Connection.cpp:160
Connection & getConnection() const
Helper method to access the underlying Connection from the Account.
Definition: Lobby.cpp:192
Account & getAccount() const
Retrive the Account which this lobbby is bound to.
Definition: Lobby.h:50
std::string m_fullName
the name, i.e account.GetName()
Definition: Person.h:35
void msg(const std::string &msg)
Definition: Person.cpp:47
Person(Lobby &l, const Atlas::Objects::Entity::Account &acc)
create a person from sight
Definition: Person.cpp:24
const std::string m_id
the account ID
Definition: Person.h:34
void sight(const Atlas::Objects::Entity::Account &acc)
update a person based on sight
Definition: Person.cpp:32
Lobby & m_lobby
the lobby owning this Person
Definition: Person.h:37
Definition: Account.cpp:33
std::int64_t getNewSerialno()
operation serial number sequencing
Definition: Connection.cpp:390