löve-ws - A websocket client and server library

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
User avatar
holywyvern
Prole
Posts: 8
Joined: Wed Apr 05, 2017 7:06 pm
Contact:

löve-ws - A websocket client and server library

Post by holywyvern »

Hello to all,

I have to admit than after a lot of testings I must say I love löve more as it grows bigger. The only "problem" I had with it is the lack of https/websocket support.

But say no more! I managed to make a library in c++ to allow the use of websockets on löve.

This is my first real experience using C++ and in creating a lua native library. I know, there might be a lot of parts to optimize (specially because I just use a lot of std::string directly instead of references) but I was looking for a way to start prototyping quickly.

If you want to check it out, you can have a look here: https://github.com/holywyvern/love-ws

If you know a bit of CMAKE/C++ and can help to export it to linux/windows/apple/android in 32 or 64 bits
I would be grateful.
User avatar
Ulydev
Party member
Posts: 445
Joined: Mon Nov 10, 2014 10:46 pm
Location: Paris
Contact:

Re: löve-ws - A websocket client and server library

Post by Ulydev »

Wait what?? That’s amazing!!
User avatar
holywyvern
Prole
Posts: 8
Joined: Wed Apr 05, 2017 7:06 pm
Contact:

Re: löve-ws - A websocket client and server library

Post by holywyvern »

You can test it now, there is a binary release in github to download.
You just need to add the DLL in your love.exe path (or project path) and do a "require('ws')"

But onlt for windows 32 bits, the 64 bit version is being impossible to compile for now... I guess in linux it may be easier, because openssl and lua are more available on that platform.

EDIT: I made it to work on winows in 64 bits... But it's still a mess to build
User avatar
Davidobot
Party member
Posts: 1226
Joined: Sat Mar 31, 2012 5:18 am
Location: Oxford, UK
Contact:

Re: löve-ws - A websocket client and server library

Post by Davidobot »

Nice work! What is the advantage of using WebSockets over say the default

Code: Select all

require("socket')
or enet?
PM me on here or elsewhere if you'd like to discuss porting your game to Nintendo Switch via mazette!
personal page and a raycaster
User avatar
holywyvern
Prole
Posts: 8
Joined: Wed Apr 05, 2017 7:06 pm
Contact:

Re: löve-ws - A websocket client and server library

Post by holywyvern »

First of all, these are websockets and not plain TCP/UDP sockets, this means users connects using http/https first and request an upgrade wich keeps the connection alive to the server. UDP is not reliable and TCP is the protocol used by websockets, but websockets add an extra layer than keeps checking the connection using ping.

That aside, this also supports TLS, this means than you can connect to a server with TLS certificates (the ability to create a server is not done because simple-websocket-server uses boost filesystem and I'm trying to avoid that for now, and also, you may have to make your users create their own certificates) wich means your connection between server and client is encrypted.

For multiplayer games than are between two games and don't have a server in between, luasocket and lua-enet are better alternatives.
If you are developing some type of multiplayer game in wich your users connect into your server, you can use lua-enet or luasockets, but the connections will be vulnerable to "man in the middle" attacks. Using TLS if someone reads what are you sending to the server, they'll still need to decrypt it using the server's private key, wich of course it's really hard to guess for a computer.

You can encrypt your data with your own custom lua code and send it via a normal socket, but encryption is slow.

I hope this clears all, if you need anything else, please ask.
Post Reply

Who is online

Users browsing this forum: No registered users and 35 guests