dibok
Hi,
I’m trying to use phoenix.js in my Qt QML project which has it’s own buildin JavaScript engine. Problem is that (what I googled so far) that this engine has cut out WebSocket class, because QML has its own WebSocket component. When I import phoenix.js library and try to create Socket then I get error:
TypeError: Cannot read property 'WebSocket' of undefined
Problem is probably in this line:
this.transport = opts.transport || global.WebSocket || LongPoll;
So in theory, it is possible to inject QML WebSocket{} engine in phoenix.js by Qt.createQmlObject() or Qt.createComponent(). But this probably require change names of original WebSocket’s method names and signals etc. in phoenix.js file.
Did anyone tried this? I’m still newbie in QML and JavaScript, as C++ and Qt Widgetsets programmer, I’m trying to make new project using QML framework so I’m not such experienced to do it by my self.
Regards
Trending in Proposals: Ideas
Other Trending Topics
Latest Phoenix Threads
Latest on Elixir Forum
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #blog-post
- #ai
- #phoenix_html
- #iex
- #elixirconf-us
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 9- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
thomas.fortes
Hi and welcome
How are you initializing your socket?
The phoenix.js docs have a list of options that you can pass when initializing it and transport is one of the options which would allow you to override (as you can see in the line that you highlighted as the source of the error).
dibok
Hi,
Thanks for reply.
I’m importing phoenix in my QML by this:
And creating:
I tried now with:
But getting error:
linusdm
I remember that this Qt JavaScript environment is a pita to work with…
What are you trying to accomplish? You want to interact and display a remote LiveView application? Or do you want to communicate with a Phoenix channel from within your Qt application?
dibok
Well. My friend is writting kind of chat (with rooms etc) using phoenix serwer. Beside WebApp client, we want to also have lightweight multiplatform desktop app which also cover mobiles. As a desktop programmer who have some experience with Qt Widgetsets C++ framework, decided to use Qt Quick QML framework to gain practice
linusdm
If you’re only interested in communicating through a channel, then you don’t really need to use the javascript runtime. I think there are implementations in C and C++ to connect to a Phoenix Channel (can’t find it right now, so if anyone knows where to find those other language bindings, pls share).
If you want to display a LV, then you’ll have to solve this indeed. Or use another way to package your application. There are a few other ways to package a Phoenix app for desktop. Check LiveView Native for mobile.
dibok
Thanks for hints. I’ll do some research this evening. If indeed there is some unofficial C++ wrapper for phoenix then I can still use it in QML, because C++ is backend for QML and you can share C++ objects between Qt JavaScript and backend
LostKobrakai
dibok
There is no wrappers for C/C++
. Seems that I must search for some unofficial
dibok
Look like there is no good C++ wrappers for phoenix. This one wasn’t updated from 7 years so I guess it will not work
https://github.com/jojojames/PhxSocketCPP