Exemplo n.º 1
0
    def _init_rpc_server(self):
        _uri = self._broker_endpoint.uri
        _host = self._broker_endpoint.broker_ref.host
        _port = self._broker_endpoint.broker_ref.port
        _vhost = self._broker_endpoint.broker_ref.vhost

        _username = self._broker_endpoint.auth.username
        _password = self._broker_endpoint.auth.password

        _broker_conn_params = amqp_common.ConnectionParameters(host=_host,
                                                               port=_port,
                                                               vhost=_vhost)

        _broker_conn_params.credentials = amqp_common.Credentials(
            _username, _password)

        self._broker_rpc_server = amqp_common.RpcServer(
            _uri,
            on_request=self._broker_rpc_callback,
            connection_params=_broker_conn_params,
            debug=True)
Exemplo n.º 2
0
    def _init_broker_publisher(self):
        """_init_broker_publisher"""
        _uri = self._broker_endpoint.uri
        _host = self._broker_endpoint.broker_ref.host
        _port = self._broker_endpoint.broker_ref.port
        _vhost = self._broker_endpoint.broker_ref.vhost

        _username = self._broker_endpoint.auth.username
        _password = self._broker_endpoint.auth.password

        _broker_conn_params = amqp_common.ConnectionParameters(host=_host,
                                                               port=_port,
                                                               vhost=_vhost)

        _broker_conn_params.credentials = amqp_common.Credentials(
            _username, _password)

        self._broker_pub = amqp_common.PublisherSync(
            _uri, connection_params=_broker_conn_params)

        rospy.loginfo('AMQP Publisher <{}> ready!'.format(_uri))
Exemplo n.º 3
0
    def _init_broker_subscriber(self):
        """_init_broker_subscriber"""
        _uri = self._broker_endpoint.uri
        _host = self._broker_endpoint.broker_ref.host
        _port = self._broker_endpoint.broker_ref.port
        _vhost = self._broker_endpoint.broker_ref.vhost

        _username = self._broker_endpoint.auth.username
        _password = self._broker_endpoint.auth.password

        _broker_conn_params = amqp_common.ConnectionParameters(host=_host,
                                                               port=_port,
                                                               vhost=_vhost)

        _broker_conn_params.credentials = amqp_common.Credentials(
            _username, _password)

        self._broker_sub = amqp_common.SubscriberSync(
            _uri,
            on_message=self._broker_sub_callback,
            connection_params=_broker_conn_params,
            queue_size=10)
        rospy.loginfo('AMQP Subscriber <{}> ready!'.format(_uri))
        self._broker_sub.run_threaded()
Exemplo n.º 4
0
                        const=True,
                        nargs='?')

    args = parser.parse_args()
    host = args.host
    port = args.port
    vhost = args.vhost
    username = args.username
    password = args.password
    device_id = args.device_id
    fpath = args.fpath
    app_type = args.app_type
    app_id = args.app_id
    rpc_name = args.rpc_name
    debug = True if args.debug else False

    conn_params = amqp_common.ConnectionParameters(host=host,
                                                   port=port,
                                                   vhost=vhost)
    conn_params.credentials = amqp_common.Credentials(username, password)

    rpc_name = rpc_name.format(device_id)
    rpc_client = amqp_common.RpcClient(rpc_name, connection_params=conn_params)
    fmsg = amqp_common.FileMessage()
    fmsg.load_from_file(fpath)
    msg = AppDownloadMessage(app_id, app_type, fmsg)

    rpc_client.debug = True
    resp = rpc_client.call(msg.to_dict(), timeout=30)
    pprint(resp)