Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get map with C++ API #227

Open
atimin opened this issue Jun 2, 2021 · 0 comments
Open

How to get map with C++ API #227

atimin opened this issue Jun 2, 2021 · 0 comments

Comments

@atimin
Copy link

atimin commented Jun 2, 2021

Hey again, I'm going deeper with WAMP and faced another problem.

I have a callee in python providing a procedure that should return a map:

from autobahn.asyncio.component import Component, run

from config_service.config import Config

config = Config()

component = Component(transports=[{'type': 'rawsocket', 'url': config.wamp_router}], realm=config.wamp_realm)


@component.on_join
def joined(session, details):
    def get_settings():
        return {"param1": 1, "param2": True, "param3": 2.0, "param4": "string"}

    session.register(get_settings, config.wamp_prefix + '.get')


if __name__ == "__main__":
    run([component])

I'm trying to call the procedure and get data in C++:

 session->call("adt.settings.get")
                .then([&](boost::future<autobahn::wamp_call_result> result) {
                  try {
                    auto ret = result.get();
                    LOG_INFO() << ret.kw_argument<int>("param1");
                  } catch (const std::exception& e) {
                    LOG_ERROR() << e.what();
                    io.stop();
                    return;
                  }
...

This code doesn't work and I have an exception : param1 keyword argument doesn't exist

In the logs and debug mode I see that the map is wrapped into an array:

RawSocket handshake reply received
connect successful: valid handshake
RX preparing to receive message ..
TX message (122 octets) ...
TX message: hello ["adt", {"authid":"","authmethods":[],"roles":{"subscriber":{},"publisher":{},"callee":{"features":{"call_timeout":true}},"caller":{"features":{"call_timeout":true}}}}]
RX message (844 octets) ...
RX message received.
RX message: welcome [4951396766928797, {"x_cb_node":"043ac2c80af9-1","x_cb_worker":"worker001","x_cb_peer":"tcp4:172.22.0.1:35404","x_cb_pid":21,"realm":"adt","authid":"NN6M-VRGE-JSN9-3F64-E5TM-W35Y","authrole":"anonymous","authmethod":"anonymous","authprovider":"static","authextra":{"x_cb_node":"043ac2c80af9-1","x_cb_worker":"worker001","x_cb_peer":"tcp4:172.22.0.1:35404","x_cb_pid":21},"roles":{"broker":{"features":{"publisher_identification":true,"pattern_based_subscription":true,"session_meta_api":true,"subscription_meta_api":true,"subscriber_blackwhite_listing":true,"publisher_exclusion":true,"subscription_revocation":true,"payload_transparency":true,"payload_encryption_cryptobox":true,"event_retention":true}},"dealer":{"features":{"caller_identification":true,"pattern_based_registration":true,"session_meta_api":true,"registration_meta_api":true,"shared_registration":true,"call_canceling":true,"progressive_call_results":true,"registration_revocation":true,"payload_transparency":true,"testament_meta_api":true,"payload_encryption_cryptobox":true}}}}]
RX preparing to receive message ..
TX message (21 octets) ...
TX message: call [1, {}, "adt.settings.get"]
RX message (138 octets) ...
RX message received.
RX message: result [1, {"callee":7189193259188515,"callee_authid":"NR3E-VAHH-M4V3-4YXC-7AS9-3QRK","callee_authrole":"anonymous"}, [{"param1":1,"param2":true,"param3":2,"param4":"string"}]]
RX preparing to receive message ..

However I can't figure out the way to extract it properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant