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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <Eris/Person.h>
#include <Eris/LogStream.h>
#include <Eris/Exceptions.h>
#include <Eris/Lobby.h>
#include <Eris/Connection.h>
#include <Eris/Account.h>
#include <Atlas/Objects/Entity.h>
#include <Atlas/Objects/Anonymous.h>
#include <Atlas/Objects/Operation.h>
typedef Atlas::Objects::Entity::Account AtlasAccount;
using namespace Atlas::Objects::Operation;
using Atlas::Objects::Entity::Anonymous;
using Atlas::Objects::Root;
namespace Eris
{
Person::Person(Lobby *l, const AtlasAccount &acc) :
m_id(acc->getId()),
m_fullName(acc->getName()),
m_lobby(l)
{
}
void Person::sight(const AtlasAccount &acc)
{
if (acc->getId() != m_id)
{
error() << "person got sight(account) with mismatching Ids";
return;
}
if (acc->isDefaultName())
m_fullName = m_id;
else
m_fullName = acc->getName();
}
void Person::msg(const std::string &msg)
{
if (!m_lobby->getConnection()->isConnected())
{
error() << "sending private chat, but connection is down";
return;
}
Anonymous speech;
speech->setAttr("say",msg);
Talk t;
t->setArgs1(speech);
t->setTo(m_id);
t->setFrom(m_lobby->getAccount()->getId());
t->setSerialno(getNewSerialno());
m_lobby->getConnection()->send(t);
}
} // of namespace Eris
|