Bugfix: relaunch the client when on settings validation (new login/password for example)

This commit is contained in:
Laurent Clouet
2015-01-27 21:44:32 +00:00
parent f1c5738dd5
commit c801835c83
4 changed files with 37 additions and 5 deletions

View File

@@ -48,6 +48,8 @@ public class GuiSwing extends JFrame implements Gui {
private boolean waitingForAuthentication;
private Client client;
private ThreadClient threadClient;
public GuiSwing() {
framesRendered = 0;
@@ -158,6 +160,14 @@ public class GuiSwing extends JFrame implements Gui {
notifyAll();
}
if (threadClient != null && threadClient.isAlive()) {
System.out.println("Old thread client is alive, do not regenerate one");
}
else {
threadClient = new ThreadClient();
threadClient.start();
}
showActivity(ActivityType.WORKING);
}
@@ -175,4 +185,15 @@ public class GuiSwing extends JFrame implements Gui {
setVisible(true);
panel.repaint();
}
public class ThreadClient extends Thread {
@Override
public void run() {
if (GuiSwing.this.client != null) {
int ret = GuiSwing.this.client.run();
System.out.println("Client.run return " + ret);
}
}
}
}

View File

@@ -27,6 +27,8 @@ public class GuiText implements Gui {
private int framesRendered;
private Log log;
private Client client;
public GuiText() {
this.framesRendered = 0;
this.log = Log.getInstance(null);
@@ -34,6 +36,10 @@ public class GuiText implements Gui {
@Override
public void start() {
if (client != null) {
client.run();
client.stop();
}
}
@Override
@@ -66,11 +72,12 @@ public class GuiText implements Gui {
@Override
public void setClient(Client cli) {
client = cli;
}
@Override
public Client getClient() {
return null;
return client;
}
}

View File

@@ -9,6 +9,8 @@ public class GuiTextOneLine implements Gui {
private String status;
private String line;
private Client client;
public GuiTextOneLine() {
rendered = 0;
remaining = 0;
@@ -18,6 +20,10 @@ public class GuiTextOneLine implements Gui {
@Override
public void start() {
if (client != null) {
client.run();
client.stop();
}
}
@Override
@@ -50,11 +56,12 @@ public class GuiTextOneLine implements Gui {
@Override
public void setClient(Client cli) {
client = cli;
}
@Override
public Client getClient() {
return null;
return client;
}
private void updateLine() {

View File

@@ -291,8 +291,5 @@ public class Worker {
hook.attachShutDownHook();
gui.start();
cli.run();
cli.stop();
}
}