-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSenaTCPListener.java
More file actions
45 lines (35 loc) · 951 Bytes
/
SenaTCPListener.java
File metadata and controls
45 lines (35 loc) · 951 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import Console.Console;
public class SenaTCPListener implements Runnable {
BufferedReader inFromServer;
String buffer;
Console console;
SenaTCPListener(Socket clientSocket, Console output) {
try {
console = output;
inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public void run() {
boolean cond=true;
while(cond) {
try {
buffer = inFromServer.readLine();
if (!buffer.startsWith("Ticks") && !buffer.startsWith("Seconds") && !buffer.equals("")) {
System.out.println(buffer);
console.write(buffer);
}
} catch (IOException e) {
cond=false;
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}