示例#1
0
void ClientConnection::processTalk(const Atlas::Objects::Operation::Talk& tk)
{
    if (m_server->m_rooms.count(tk->getTo()))
        return m_server->talkInRoom(tk, tk->getTo());
    
    if (m_server->m_accounts.count(tk->getTo())) {
        ClientConnection* cc = m_server->getConnectionForAccount(tk->getTo());
        if (!cc) {
            sendError("oog chat: account is offline", tk);
            return;
        }
        
        Sound snd;
        snd->setFrom(m_account); 
        snd->setArgs1(tk);
        snd->setTo(cc->m_account);
        cc->send(snd);
        return;
    }
    
    if (tk->getTo().empty()) {
        // lobby chat
        return m_server->talkInRoom(tk, "_lobby");
    }
    
    sendError("bad TO for OOG TALK op: " + tk->getTo(), tk);
}
int main()
{
    ClientConnection * cc = new ClientConnection();
    delete cc;

    // Try all the method calls when not connected
    cc = new ClientConnection();

    cc->login("username", "password");
    cc->create("player", "username", "password");
    cc->wait();

    {
        Atlas::Objects::Operation::RootOperation op;
        cc->send(op);
    }

    cc->pop();
    cc->pending();
    
    delete cc;

    TestClientConnection * tcc = new TestClientConnection();

    {
        Atlas::Objects::Root obj;
        Atlas::Objects::Operation::RootOperation op;
        tcc->test_operation(op);
        tcc->test_errorArrived(op);
        tcc->test_infoArrived(op);
        tcc->test_objectArrived(op);

        Anonymous op_arg;
        op->setArgs1(op_arg);
        tcc->test_infoArrived(op);

        op->setFrom("1");
        tcc->test_infoArrived(op);

        op->setParents(std::list<std::string>());
        tcc->test_operation(op);
        tcc->test_objectArrived(op);

        Info i;
        tcc->test_objectArrived(i);

        Error e;
        tcc->test_objectArrived(e);

        tcc->test_objectArrived(obj);
        obj->setParents(std::list<std::string>());
        tcc->test_objectArrived(obj);

        
    }

    return 0;
}
示例#3
0
static void lookAtEntity(ClientConnection& con, const std::string & eid,
                                                const std::string & loc)
{
    Look l;
    l->setFrom(con.getCharacterId());
    Anonymous lookEnt;
    lookEnt->setId(eid);
    l->setArgs1(lookEnt);
    int serial = con.send(l);
    
    verbose( std::cout << "Waiting for In-game look response on connection "
                       << con.getAccount() << std::endl << std::flush; );