WebSocket on love-android

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Paltze
Prole
Posts: 10
Joined: Mon Aug 09, 2021 9:33 am

WebSocket on love-android

Post by Paltze »

I am trying to make a multiplayer game with Node.js as backend. I am deploying it on Heroku. As Heroku does not support TCP (at least on free and hobby tier), I have to use WebSockets. I found several libraries for WebSockets, such as: These have either C or C++ dependencies or written in C++ itself. But I was not able to find any documentation on how to use C or C++ dependencies with love-android(there's also the hassle of compiling it for my desktop platform for developing and testing).

I also found this websocket client written in pure lua: https://github.com/flaribbit/love2d-lua-websocket. It works perfectly when my server is running on localhost but connects and then disconnects immediately (according to STATUS property provided by the library) when I try to connect to my deployed server on Heroku. I tried other WebSocket clients and a Node client I wrote myself and they work properly. So it is a problem with this library.

Please either point out the problem with flaribbit's websocket implementation or point to a tutorial about how to use C and C++ modules with love-android. Of course, I would prefer if I can work with flaribbit's websocket implementation as it rules out a whole lot of hassle of compilation.
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: WebSocket on love-android

Post by grump »

I don't know much about Heroku or any of those libraries, but I'm pretty sure your local server doesn't use TLS, while Heroku most probably does, as any respectable web service should. WebSockets over TLS are strongly encrypted; the Lua library does not support that.

I don't think a pure Lua implementation of a TLS-capable sockets library exists. I've implemented WebSockets clients incl. TLS in Lua before with luvit. I don't know if there's a way to use luvit with love2d though, or whether Android is supported at all. Look it up and find out.

Or you could rent a VPS if you can spare like $5 USD a month. You can run whatever you want on those.
Paltze
Prole
Posts: 10
Joined: Mon Aug 09, 2021 9:33 am

Re: WebSocket on love-android

Post by Paltze »

Is there a way to use C and C++ libraries with love-android? Because I googled it and can't find a way to use luvit with Love2D. I will look into VPS but I don't really want to shell out money on a hobby project, more so, when I am not sure the project can return the investment.
User avatar
EngineerSmith
Prole
Posts: 38
Joined: Thu Dec 02, 2021 11:38 am
Contact:

Re: WebSocket on love-android

Post by EngineerSmith »

I've done it before to get ssl curl working, you had to put the shared library (*.so) in a certain location (with the other shared libraries so just look around in it within the android folders) and then you can just load it with ffi
Paltze
Prole
Posts: 10
Joined: Mon Aug 09, 2021 9:33 am

Re: WebSocket on love-android

Post by Paltze »

Can you please explain in detail how to compile to *.so file and where exactly to place them? Thank you so much for you help.
mhxiy
Prole
Posts: 3
Joined: Wed Dec 11, 2024 7:30 pm

Re: WebSocket on love-android

Post by mhxiy »

Paltze wrote: Fri Dec 31, 2021 6:51 am Can you please explain in detail how to compile to *.so file and where exactly to place them? Thank you so much for you help.
Looking for this 3 years in the future now, lol. Would appreciate an answer to this if you managed to figure it out. Much love
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Amazon [Bot] and 9 guests