Jump to content
PerEspen00

Destory a host in luaenet

Recommended Posts

Hi!

 

I'm using luaenet for my game and it's going well, but I can't seem to make a disconnect option. I don't know if I'm understanding it correctly or not, but I can't find an option where you can disconnect a host, or destroy one. So I'm looking for a way to disconnect a host.

 

Website for the luaenet: http://leafo.net/lua-enet/#peerdisconnectdata

Post I used to download: http://www.leadwerks.com/werkspace/topic/14699-networking-in-lua/#entry99965

 

Any help appreciated.

Share this post


Link to post

I would imagine they have it configured to destroy the host using the the lua garbage collector....

What you can try doing is printing out the "enet" table and see if it has "enet.host_destroy" as that would follow the general style they're going for since the C++ version would be like:

enet_host_destroy(components.host);

 

If it's not there you could definitely expose it yourself (push it to "enet" module.) then manually handle deletion... or even not use lua-enet all together and generate your own bindings with toLua++ and a pkg generator like the one me or Josh released on here. (think would require adding //lua comments to the enet header files.) (Then you'd have to ensure you manually destroyed the host though, as it wouldn't be config'd to work w/ the GC.)

 

But yeah if all references to the host become nil it should delete itself

local host = enet.host_create"localhost:6789"
host = nil -- the host will now be garbage collected.

.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...