Page 2 of 2

Re: Lua Enet IPv6

Posted: Fri Jan 25, 2019 1:54 am
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 42 times
server.love
(8.8 KiB) Downloaded 43 times

Re: Lua Enet IPv6

Posted: Fri Jan 25, 2019 1:48 pm
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.

Re: Lua Enet IPv6

Posted: Sat Jan 26, 2019 6:23 am
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 60 times
Thanks!