sock.lua icon indicating copy to clipboard operation
sock.lua copied to clipboard

Client:connect() does not return anything

Open thebenign opened this issue 9 years ago • 3 comments

The documentation states that Client:connect() will return a boolean value indicating whether the connection was successful or not. It currently returns nil in every case.

thebenign avatar Oct 22 '16 17:10 thebenign

You're right, and the documentation has been corrected in some of the more recent updates. (Which will come soon!) The actual connection event doesn't occur until the next time the client and server are updated. So, there's no way to tell if a connection succeeded at the time the connect method is called.

camchenry avatar Oct 22 '16 17:10 camchenry

Thanks for the reply! I did notice that when I looked through the code. It makes sense with how enet handles peer creation / connection. Do you plan to implement this feature some other way?

thebenign avatar Oct 24 '16 02:10 thebenign

For now, you can just set some connected state when the "connect" event goes off.

-- client code
connected = false

client:connect()

client:on("connect", function()
    connected = true
end)

camchenry avatar Oct 27 '16 22:10 camchenry