template<class T> void AsyncEndpoint<T>::stop()
{
    if(persist){
        AsyncEndpoint<T>::deactivateSession(this->shared_from_this());
        log("Session deactivated");
    }
    else{
        unregisterEndpoint();
    }
}
void NMEAEndpoint::add_midpoint_cmd(Command_ptr command){
    try{
        NMEAMidpoint_ptr midpoint = NMEAMidpoint::factory(getConnectedTo(),command->getArguments());
        unregisterEndpoint();
        setConnectedTo(midpoint);
        registerEndpoint();
        
        command->answer("Midpoint created and connected.", shared_from_this());
    }
    catch(std::exception& e){
        command->answer(Answer::WRONG_ARGS, "Cannot understand "+command->getArguments()+" for command "+command->getCommand()+". Not a midpoint class\n", shared_from_this());
    }
}
void 
HippoListenerProxyImpl::unregisterAllEndpoints()
{
    while (!endpoints_.empty())
        unregisterEndpoint(hippo_endpoint_proxy_get_id(endpoints_.front()));
}
void ConfigEndpoint::close(){
    unregisterEndpoint();
}