File tree Expand file tree Collapse file tree
src/main/java/com/github/theholywaffle/teamspeak3 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2727 */
2828
2929import com .github .theholywaffle .teamspeak3 .api .Callback ;
30+ import com .github .theholywaffle .teamspeak3 .commands .CQuit ;
3031import com .github .theholywaffle .teamspeak3 .commands .Command ;
3132
3233import java .io .BufferedReader ;
@@ -73,13 +74,15 @@ public void run() {
7374 line = in .readLine ();
7475 } catch (IOException io ) {
7576 if (!isInterrupted ()) {
76- io . printStackTrace ( );
77+ TS3Query . log . log ( Level . WARNING , "Connection error occurred." , io );
7778 }
7879 break ;
7980 }
8081
8182 if (line == null ) {
82- break ; // The underlying socket was closed
83+ // End of stream: connection terminated by server
84+ TS3Query .log .warning ("Connection closed by the server." );
85+ break ;
8386 } else if (line .isEmpty ()) {
8487 continue ; // The server is sending garbage
8588 }
@@ -102,6 +105,11 @@ public void run() {
102105 } else if (c != null && c .isSent ()) {
103106 TS3Query .log .info ("[" + c .getName () + "] < " + line );
104107 if (line .startsWith ("error" )) {
108+ if (c instanceof CQuit ) {
109+ // Response to a quit command received, we're done
110+ interrupt ();
111+ }
112+
105113 c .feedError (line .substring ("error " .length ()));
106114 if (c .getError ().getId () != 0 ) {
107115 TS3Query .log .severe ("TS3 command error: " + c .getError ());
Original file line number Diff line number Diff line change @@ -120,8 +120,8 @@ public void exit() {
120120 // This will guarantee that all previously sent commands have been processed
121121 doCommand (new CQuit ());
122122
123- userThreadPool .shutdown ();
124123 io .disconnect ();
124+ userThreadPool .shutdown ();
125125 for (final Handler lh : log .getHandlers ()) {
126126 log .removeHandler (lh );
127127 }
You can’t perform that action at this time.
0 commit comments