Kleine aanpassingen gemaakt aan (Lan)TextDevice
This commit is contained in:
@@ -7,18 +7,14 @@ import pm.Device;
|
||||
public class LanTextDevice extends Device implements Runnable {
|
||||
static final int PORT = 1234;
|
||||
|
||||
ServerSocket socket;
|
||||
protected ServerSocket socket;
|
||||
|
||||
public LanTextDevice() {
|
||||
public void initialise() {
|
||||
try {
|
||||
socket = new ServerSocket(PORT);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
initialise();
|
||||
}
|
||||
|
||||
public void initialise() {
|
||||
new Thread(this).start();
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import pm.Task;
|
||||
import pm.task.TaskGatherer;
|
||||
|
||||
public class LanTextListener implements Runnable {
|
||||
static final int SLEEP = 50;
|
||||
static final int SLEEP = 100;
|
||||
|
||||
protected boolean run;
|
||||
protected Socket socket;
|
||||
@@ -19,7 +19,7 @@ public class LanTextListener implements Runnable{
|
||||
public LanTextListener(Socket socket){
|
||||
this.socket = socket;
|
||||
try {
|
||||
this.input = new Scanner(socket.getInputStream());
|
||||
input = new Scanner(socket.getInputStream());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -9,27 +9,21 @@ import pm.Task;
|
||||
import pm.task.TaskGatherer;
|
||||
|
||||
public class TextDevice extends Device implements Runnable {
|
||||
static final int SLEEP = 50;
|
||||
static final int SLEEP = 100;
|
||||
|
||||
protected boolean run;
|
||||
protected Scanner input;
|
||||
|
||||
public TextDevice() {
|
||||
initialise();
|
||||
run = true;
|
||||
public void initialise() {
|
||||
input = new Scanner(System.in);
|
||||
new Thread(this).start();
|
||||
}
|
||||
|
||||
public void initialise() {
|
||||
input = new Scanner(System.in);
|
||||
}
|
||||
|
||||
public void run() {
|
||||
System.out.println("TextDevice activated");
|
||||
run = true;
|
||||
while (run) {
|
||||
String textinput = input.next().toUpperCase();
|
||||
if(textinput != null) {
|
||||
System.out.println(textinput);
|
||||
try {
|
||||
TaskGatherer.add(
|
||||
new Task(Action.valueOf(textinput), Target.APPLICATION));
|
||||
|
||||
Reference in New Issue
Block a user