Gikkman / Java-Twirk

Small, basic library for communication via the Twitch chat. Java 8 compatible
MIT License
54 stars 22 forks source link

Calling connect after previously calling close fails #26

Closed SRabbelier closed 4 years ago

SRabbelier commented 4 years ago

After creating a Twirk instance, calling connect(), close(), connect(), results in:

java.net.SocketException: Socket is closed

This seems to be because in the 4.0 rewrite, createResources no longer creates a new socket and releaseResources does still close the socket.

Gikkman commented 4 years ago

Hm, looks like you are right.

I vaguely remember I moved the socket creation out to a dedicated socket factory, so that users could provide their own. I must have forgotten to request a new socket from the factory once I closed the old socket.

I assume the way to go about this is keeping a reference to the socket factory that's passed to the Twirk builder, and request a socket from that one when we create resources.

Thanks for the report. I'll take a look at it.