-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientReceiver.java
More file actions
37 lines (31 loc) · 789 Bytes
/
Copy pathClientReceiver.java
File metadata and controls
37 lines (31 loc) · 789 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
import java.util.ArrayList;
import java.util.LinkedList;
import java.lang.Thread;
import java.net.*;
import java.io.*;
@SuppressWarnings("unused")
public class ClientReceiver extends Thread{
private BufferedReader clientReader;
public void run(){
//TODO: fix true loop
while(true){
try{
Thread.sleep(100);
String message;
if(clientReader.ready()){
if((message = clientReader.readLine())!= null){
System.out.println(message);
}
}
//Sleep for 100 miliseconds if message is null
}catch(Exception e){
System.out.println("ClientReceiver: " + e);
System.exit(1);
}
}
}
ClientReceiver(BufferedReader in){
clientReader = in;
//takes the input stream from the server socket connected to client instance
}
}