Always close twitch client in connect() method

In case user cleared their crendentials this method should still at
least close the client so it will not be running forever.

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>
This commit is contained in:
Tomas Slusny
2019-03-20 14:23:46 +01:00
parent 4e47a25438
commit 25b5095375

View File

@@ -99,6 +99,13 @@ public class TwitchPlugin extends Plugin implements TwitchListener, ChatboxInput
private synchronized void connect() private synchronized void connect()
{ {
if (twitchIRCClient != null)
{
log.debug("Terminating Twitch client {}", twitchIRCClient);
twitchIRCClient.close();
twitchIRCClient = null;
}
if (!Strings.isNullOrEmpty(twitchConfig.username()) if (!Strings.isNullOrEmpty(twitchConfig.username())
&& !Strings.isNullOrEmpty(twitchConfig.oauthToken()) && !Strings.isNullOrEmpty(twitchConfig.oauthToken())
&& !Strings.isNullOrEmpty(twitchConfig.channel())) && !Strings.isNullOrEmpty(twitchConfig.channel()))
@@ -111,11 +118,6 @@ public class TwitchPlugin extends Plugin implements TwitchListener, ChatboxInput
log.debug("Connecting to Twitch as {}", twitchConfig.username()); log.debug("Connecting to Twitch as {}", twitchConfig.username());
if (twitchIRCClient != null)
{
twitchIRCClient.close();
}
twitchIRCClient = new TwitchIRCClient( twitchIRCClient = new TwitchIRCClient(
this, this,
twitchConfig.username(), twitchConfig.username(),