Lua Enet IPv6

General discussion about LÖVE, Lua, game development, puns, and unicorns.
EliterScripts
Citizen
Posts: 85
Joined: Sat Oct 25, 2014 7:07 pm

Re: Lua Enet IPv6

Post by EliterScripts »

Okay, so I spent today cleaning up the server code. I put together a version for demonstration purposes, since I don't want to put my entire game's code out in plaintext. I was able to get a consistent response where when the client joins, it shows, when the client leaves (nicely or not), it gets dropped and removed.

I get a consistent response with one client making requests on the first server start and first client connect. However, it gets very inconsistent if I add one more client, drop connections, connect back before the server realizes the client is gone. I don't really understand what is going on.

Also, I would like to know if it is a good or bad idea to have every client connection handled on its own thread, because I am noticing the server responses don't really seem as fast I want, especially when multiple clients are connected.


Thanks!
client.love
(1.76 KiB) Downloaded 123 times
server.love
(8.8 KiB) Downloaded 119 times
grump
Party member
Posts: 947
Joined: Sat Jul 22, 2017 7:43 pm

Re: Lua Enet IPv6

Post by grump »

I had a quick look, but couldn't run the client due to a syntax error.

Code: Select all

Error: Syntax error: main.lua:25: 'end' expected (to close 'while' at line 17) near 'if'
An unrelated note: at least in one place the code looks like this:

Code: Select all

while true
    local function abc() ... end
    local function xyz() ... end
   ...
end
While not exactly wrong, this construction will needlessly strain the gargabe collector and lower performance. Those functions get redefined at every loop iteration, throwing away the previous definition. Move the functions out of that loop if optimal performance is desired.
EliterScripts
Citizen
Posts: 85
Joined: Sat Oct 25, 2014 7:07 pm

Re: Lua Enet IPv6

Post by EliterScripts »

I edited some code. Thank you for your function suggestion! I just need to get the code to work, then I'll work it out how to design it better.

Here is the updated LOVE code for the client that SHOULD work:
client.love
(1.71 KiB) Downloaded 313 times
Thanks!
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 59 guests