SpockBotMC / SpockBot

High level Python framework for building Minecraft clients and bots.
MIT License
198 stars 47 forks source link

Gracefully Disconnect #38

Closed nickelpro closed 9 years ago

nickelpro commented 9 years ago

SpockBot should, if possible, gracefully disconnect when its killed rather than just dying. Not 100% sure how this works, see this PR: https://github.com/SpockBotMC/SpockBot/pull/37

Gjum commented 9 years ago

For now, at least the socket could be closed. Maybe that will be enough to tell the server that spock disconnected.

nickelpro commented 9 years ago

I already tried that, it works hit and miss. But I'll commit it anyway. Added in: 913d819dd4b65419fce03c33b82dea543f60b19b

Gjum commented 9 years ago

On my end, it's working fine now, thanks. Any reproducible cases where it misses?

nickelpro commented 9 years ago

I actually think I fixed it, during my testing I was using socket.SHUT_RDWR, in this commit I used socket.SHUT_WR which still allows the socket to recieve data from the server even though we have no intention of reading it. That seems to be what the MC server wants to see.

I'm going to call this fixed until someone proves me wrong

Gjum commented 9 years ago

Great. Now if spock could print some nice goodbye when it was killed... the other handle_*() in NetPlugin do that already.

nickelpro commented 9 years ago

Ask and you shall recieve: 4386ab60aca862517dac1189779631c62b061c46