Skip to content

Commit

Permalink
Add command to stop server
Browse files Browse the repository at this point in the history
  • Loading branch information
Pugmatt committed May 20, 2021
1 parent 8e0d78e commit fd8e8b9
Showing 1 changed file with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@

import javax.annotation.Nonnull;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import java.util.*;

public class Server {

Expand Down Expand Up @@ -98,5 +95,24 @@ public void run() {
timer.scheduleAtFixedRate(task, 0L, 60 * 1000);
}

new Thread() {
public void run() {
try {
Scanner sc = new Scanner(System.in);
while(sc.hasNextLine()) {
String cmd = sc.next();
switch(cmd) {
case "end":
case "stop":
System.exit(0);
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}.start();

}
}

0 comments on commit fd8e8b9

Please sign in to comment.