File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed
tmc-plugin/src/fi/helsinki/cs/tmc/model Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -55,15 +55,13 @@ public static void start() {
55
55
this .eventBus = TmcEventBus .getDefault ();
56
56
this .shouldReconnect = false ;
57
57
58
- initClientIfPossible ();
59
-
60
58
this .eventBus .subscribeDependent (new TmcEventListener () {
61
59
public void receive (TmcSettings .SavedEvent e ) {
62
- reconnect ();
60
+ reconnectSoon ();
63
61
}
64
62
65
63
public void receive (CourseDb .ChangedEvent e ) {
66
- reconnect ();
64
+ reconnectSoon ();
67
65
}
68
66
}, this );
69
67
@@ -73,14 +71,25 @@ public void receive(CourseDb.ChangedEvent e) {
73
71
public void run () {
74
72
ensureConnected ();
75
73
}
76
- }, CONNECTION_CHECK_INTERVAL );
74
+ }, 0 , CONNECTION_CHECK_INTERVAL );
77
75
}
78
76
79
77
private synchronized void ensureConnected () {
80
- if (client != null && client .isDisconnected ()) {
78
+ if (client == null || client .isDisconnected ()) {
81
79
initClientIfPossible ();
82
80
}
83
81
}
82
+
83
+ private void reconnectSoon () {
84
+ Thread t = new Thread () {
85
+ @ Override
86
+ public void run () {
87
+ reconnect ();
88
+ }
89
+ };
90
+ t .setDaemon (true );
91
+ t .start ();
92
+ }
84
93
85
94
private synchronized void reconnect () {
86
95
if (client != null && client .isConnected ()) {
You can’t perform that action at this time.
0 commit comments