vishnu
vishnu

Reputation: 373

How to make Autobahn-JS work in QML?

we want to use WAMP protocol to my server client applications. I have found Autobahn-js which implements The Web Application Messaging Protocol (WAMP). we would like to use QML for designing the frontend (thin client) and target Android, IOS, Windows Mobile and desktop platforms. Since Autobahn-js written in Javascript, I thought it would work. but unfortunately, it didn't.

Here is the following I did:

upon googling I came to know that "The require() function is a core function of node.js which is part of the engine. It's not something language-specific just like the window object in browser-based Javascript is not something in the Javascript language. node.js actually is: a server-side JavaScript engine, which executes JavaScript files. It is not a framework which you could load into another engine like Qt". source.

Here is my question:

  1. How can I make/build the Autobahn Js library so that I can use autobahn in qml? which is actually making node.js functions running in qml.

  2. Tough there is C++ implementation, I am not convinced in using the C++ wrapper in qml because it depends on third parties like Boost.

  3. Is it possible to make JS library which depends on node.js functions in QML ? Please let me know. Thanks

FYI: I am using Crossbar.io as router

Upvotes: 1

Views: 425

Answers (2)

oberstet
oberstet

Reputation: 22051

Try the browser version of AutobahnJS, not the NodeJS version.

If you only need WAMP inside QML, don't bother with C++ WAMP libraries (harder).

If you want to talk WAMP directly to your C++ stuff (within Qt), there are multiple C++ WAMP client libraries - however, I'm not sure how well these blend with Qt. Eg AutobahnC++ is Boost/ASIO based.

However, there was recently a post touching on this ..

Upvotes: 0

Kevin Krammer
Kevin Krammer

Reputation: 5207

You have four options

  1. change the library so that it doesn't depend on anything nodejs specific
  2. extend the QML JavaScript engine so that it provides the nodejs specific extensions
  3. run nodejs via QProcess
  4. look at some of the projects that try to provide a C/C++ interface for embedding nodejs

However, if the protocol you are intending to use has a C/C++ implementation, using that is likely the best way forward.

Upvotes: 0

Related Questions