示例#1
0
HostedObjectPtr ObjectHost::getHostedObject(const SpaceObjectReference& sporef) const {
    HostedObjectMap::const_iterator iter = mHostedObjects.find(sporef);
    if (iter != mHostedObjects.end()) {
        return iter->second;
    }
    return HostedObjectPtr();
}
示例#2
0
HostedObjectPtr ObjectHost::getCommandObject(const Command::Command& cmd, Command::Commander* cmdr, Command::CommandID cmdid) {
    String obj_string = cmd.getString("object", "");
    UUID objid(obj_string, UUID::HumanReadable());
    if (objid == UUID::null()) { // not specified, not parsed
        Command::Result result = Command::EmptyResult();
        result.put("error", "Ill-formatted request: no object specified for disconnect.");
        cmdr->result(cmdid, result);
        return HostedObjectPtr();
    }

    HostedObjectPtr ho = getHostedObject(objid);
    if (!ho) {
        Command::Result result = Command::EmptyResult();
        result.put("error", "Object not found");
        cmdr->result(cmdid, result);
        return HostedObjectPtr();
    }

    return ho;
}
示例#3
0
void HostedObject::destroy(bool need_self)
{
    // Avoid recursive destruction
    if (destroyed) return;
    if (mNumOutstandingConnections>0) {
        mDestroyWhenConnected=true;
        return;//don't destroy during delicate connection process
    }

    // Make sure that we survive the entire duration of this call. Otherwise all
    // references may be lost, resulting in the destructor getting called
    // (e.g. when the ObjectScript removes all references) and then we return
    // here to do more work and we've already been deleted.
    HostedObjectPtr self_ptr = need_self ? getSharedPtr() : HostedObjectPtr();
    destroyed = true;

    if (mObjectScript) {
        // We need to clear out the reference in storage, which will also clear
        // out leases.
        mObjectHost->getStorage()->releaseBucket(id());
        // Then clear out the script
        delete mObjectScript;
        mObjectScript=NULL;
    }

    //copying the data to a separate map before clearing to avoid deadlock in
    //destructor.

    PresenceDataMap toDeleteFrom;
    {
        Mutex::scoped_lock locker(presenceDataMutex);
        toDeleteFrom.swap(mPresenceData);
    }

    for (PresenceDataMap::iterator iter = toDeleteFrom.begin();
         iter != toDeleteFrom.end(); ++iter)
    {
        // Make sure we explicitly. Other paths don't necessarily do this,
        // e.g. if the call to destroy happens between receiving a connection
        // success and the actual creation of the stream from the space, leaving
        // other components unaware that the connection has been made. Worst
        // case, the object host/session manager ignore the request.
        mObjectHost->disconnectObject(iter->first.space(),iter->first.object());
        delete iter->second;
        // And just clear the ref out from the ObjectHost
        mObjectHost->unregisterHostedObject(iter->first,this);
    }
}
示例#4
0
HostedObjectPtr ObjectHost::getHostedObject(const UUID& internal_id) const {
    InternalIDHostedObjectMap::const_iterator iter = mHostedObjectsByID.find(internal_id);
    if (iter == mHostedObjectsByID.end()) return HostedObjectPtr();
    HostedObjectPtr ho = iter->second.lock();
    return ho;
}