void StandardLocationService::locationUpdate(UUID source, void* buffer, uint32 length) { Sirikata::Protocol::Loc::Container loc_container; bool parse_success = loc_container.ParseFromString( String((char*) buffer, length) ); if (!parse_success) { LOG_INVALID_MESSAGE_BUFFER(standardloc, error, ((char*)buffer), length); return; } if (loc_container.has_update_request()) { Sirikata::Protocol::Loc::LocationUpdateRequest request = loc_container.update_request(); TrackingType obj_type = type(source); if (obj_type == Local) { LocationMap::iterator loc_it = mLocations.find( source ); assert(loc_it != mLocations.end()); if (request.has_location()) { TimedMotionVector3f newloc( request.location().t(), MotionVector3f( request.location().position(), request.location().velocity() ) ); loc_it->second.location = newloc; notifyLocalLocationUpdated( source, loc_it->second.aggregate, newloc ); CONTEXT_SPACETRACE(serverLoc, mContext->id(), mContext->id(), source, newloc ); } if (request.has_bounds()) { BoundingSphere3f newbounds = request.bounds(); loc_it->second.bounds = newbounds; notifyLocalBoundsUpdated( source, loc_it->second.aggregate, newbounds ); } if (request.has_mesh()) { String newmesh = request.mesh(); loc_it->second.mesh = newmesh; notifyLocalMeshUpdated( source, loc_it->second.aggregate, newmesh ); } if (request.has_orientation()) { TimedMotionQuaternion neworient( request.orientation().t(), MotionQuaternion( request.orientation().position(), request.orientation().velocity() ) ); loc_it->second.orientation = neworient; notifyLocalOrientationUpdated( source, loc_it->second.aggregate, neworient ); } if (request.has_physics()) { String newphy = request.physics(); loc_it->second.physics = newphy; notifyLocalPhysicsUpdated( source, loc_it->second.aggregate, newphy ); } } else { // Warn about update to non-local object } } }
void TimeSyncServer::handleMessage(const OHDP::Endpoint& src, const OHDP::Endpoint& dst, MemoryReference payload) { SILOG(timesync, detailed, "Received time sync message from remote node " << src.node()); Sirikata::Protocol::TimeSync sync_msg; bool parse_success = sync_msg.ParseFromArray(payload.data(), payload.size()); if (!parse_success) { LOG_INVALID_MESSAGE_BUFFER(sync, error, ((char*)payload.data()), payload.size()); return; } // Our only job is to take the existing message, fill in a timestamp, and // send it back. sync_msg.set_t(mContext->simTime()); String resp = serializePBJMessage(sync_msg); mPort->send(src, MemoryReference(resp)); SILOG(timesync, detailed, "Sent time sync message reply to remote node " << src.node()); }