void PintoManager::queryHasEvents(Query* query) { typedef std::deque<QueryEvent> QueryEventList; Network::Stream* stream = mClientsByQuery[query]; ClientData& cdata = mClients[stream]; QueryEventList evts; query->popEvents(evts); Sirikata::Protocol::MasterPinto::PintoResponse msg; while(!evts.empty()) { const QueryEvent& evt = evts.front(); //PINTO_LOG(debug, "Event generated for server " << cdata.server << ": " << evt.id() << (evt.type() == QueryEvent::Added ? " added" : " removed")); Sirikata::Protocol::MasterPinto::IPintoUpdate update = msg.add_update(); for(uint32 aidx = 0; aidx < evt.additions().size(); aidx++) { Sirikata::Protocol::MasterPinto::IPintoResult result = update.add_change(); result.set_addition(true); result.set_server(evt.additions()[aidx].id()); } for(uint32 ridx = 0; ridx < evt.removals().size(); ridx++) { Sirikata::Protocol::MasterPinto::IPintoResult result = update.add_change(); result.set_addition(false); result.set_server(evt.removals()[ridx].id()); } evts.pop_front(); } String serialized = serializePBJMessage(msg); stream->send( MemoryReference(serialized), ReliableOrdered ); }
// Forwards object events from the orignal tree into the replicated location // service cache, which puts them into the query handler virtual void queryHasEvents(Query* query) { typedef std::deque<QueryEvent> QueryEventList; QueryEventList evts; query->popEvents(evts); while(!evts.empty()) { const QueryEvent& evt = evts.front(); for(size_t aidx = 0; aidx < evt.additions().size(); aidx++) { QueryEvent::Addition add = evt.additions()[aidx]; replicated_loccache->addObjectWithParent( add.id(), add.parent(), (add.type() == QueryEvent::Imposter), orig_loccache->location(add.id()), orig_loccache->centerOffset(add.id()), orig_loccache->centerBoundsRadius(add.id()), orig_loccache->maxSize(add.id()), orig_loccache->mesh(add.id()), true ); } for(size_t ridx = 0; ridx < evt.removals().size(); ridx++) { QueryEvent::Removal rem = evt.removals()[ridx]; replicated_loccache->removeObject(rem.id()); } evts.pop_front(); } }