Ejemplo n.º 1
0
    Publisher( const servus::URI& uri_, const uint32_t announceMode )
        : Sender( uri_, 0, ZMQ_PUB )
        , _service( std::string( "_" ) + uri.getScheme() + "._tcp" )
    {
        const std::string& zmqURI = buildZmqURI( uri );
        if( zmq_bind( socket, zmqURI.c_str( )) == -1 )
        {
            zmq_close( socket );
            socket = 0;
            ZEQTHROW( std::runtime_error(
                          std::string( "Cannot bind publisher socket '" ) +
                          zmqURI + "': " + zmq_strerror( zmq_errno( ))));
        }

        _initService( announceMode );
    }
Ejemplo n.º 2
0
    Impl( const URI& uri_, const std::string& session )
        : detail::Sender( uri_, 0, ZMQ_PUB )
        , _service( PUBLISHER_SERVICE )
        , _session( session == DEFAULT_SESSION ? getDefaultSession() : session )
    {
        if( session.empty( ))
            ZEROEQTHROW( std::runtime_error(
                             "Empty session is not allowed for publisher" ));

        const std::string& zmqURI = buildZmqURI( uri );
        if( zmq_bind( socket, zmqURI.c_str( )) == -1 )
        {
            zmq_close( socket );
            socket = 0;
            ZEROEQTHROW( std::runtime_error(
                             std::string( "Cannot bind publisher socket '" ) +
                             zmqURI + "': " + zmq_strerror( zmq_errno( ))));
        }

        initURI();

        if( session != NULL_SESSION )
            _initService();
    }