void Client::detach(Resource *resource)
{
    for (Resources_t::iterator it = m_resources.begin();
         it != m_resources.end();
         ++it) {
        if (it->get() == resource) {
            if (it->unique()) {
                // client was the last owner, and thus the session must be idle (otherwise
                // it would also be referenced as active session)
                boost::shared_ptr<Session> session = boost::dynamic_pointer_cast<Session>(*it);
                if (session) {
                    // give clients a chance to query the session
                    m_server.delaySessionDestruction(session);
                    // allow other sessions to start
                    session->done(false);
                }
            }
            // this will trigger removal of the resource if
            // the client was the last remaining owner
            m_resources.erase(it);
            return;
        }
    }

    SE_THROW_EXCEPTION(InvalidCall, "cannot detach from resource that client is not attached to");
}
CURL *CurlTransportAgent::easyInit()
{
    static bool initialized = false;
    static CURLcode initres;

    if (!initialized) {
        initres = curl_global_init(CURL_GLOBAL_ALL);
        initialized = true;
    }

    if (initres) {
        SE_THROW_EXCEPTION(TransportException, "global curl initialization failed");
    }
    CURL *handle = curl_easy_init();
    if (!handle) {
        SE_THROW_EXCEPTION(TransportException, "no curl handle");
    }
    return handle;
}
void CurlTransportAgent::checkCurl(CURLcode code, bool exception)
{
    if (code) {
        if(exception){
            SE_THROW_EXCEPTION(TransportException, m_curlErrorText);
        }else {
            SE_LOG_INFO(NULL, NULL, "CurlTransport Failure: %s", m_curlErrorText);
        }
    }
}