osmarks / skynet

Technically client-agnostic websocket communications server, designed for ComputerCraft
MIT License
7 stars 0 forks source link

Error at skynet.connect() on Further Connections #25

Open JWBstuhr opened 11 months ago

JWBstuhr commented 11 months ago

I've found an error caused by connecting, disconnecting, and reconnecting.

I dug around a bit, and I think it's because skynet.connect() checks skynet.socket for nil. (at L16, if not skynet.socket or force then) skynet.socket.close() doesn't set skynet.socket to nil, it remains a function that errors "Attempt to use a closed file". Because of that, it doesn't pass the check and doesn't connect to the websocket. Running skynet.connect(true) doesn't work either because of the second check, where it tries to close an already closed file. (at L18, if skynet.socket then skynet.socket.close() end)

I've found manually setting skynet.socket to nil directly after disconnecting can fix the problem; I think maybe doing that at the end of skynet.disconnect() could fix it? Not sure though.