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