-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathValidationThread.java
54 lines (48 loc) · 1.51 KB
/
ValidationThread.java
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
46
47
48
49
50
51
52
53
import java.util.*;
public class ValidationThread implements Runnable
{
Client cl;
String info;
String actualIP;
ValidationThread(Client cl, String info, String actualIP)
{
this.cl = cl;
this.info = info;
this.actualIP = actualIP;
}
@Override
public void run()
{
int i;
for(i = 0; i < 10; i++)
{
try
{
Thread.sleep(500);
if(cl == null)
{
System.out.println("No client found with IP Address matching request");
break;
}
//if(!actualIP.equals(cl.getIPAddress()))
//continue;
System.out.println("Server to Client with IP : " + cl.getIPAddress() + " Have you sent a request?");
String s = cl.validateConfirmation();
String st = "Yes, I have";
if(s.equals(st))
{
System.out.println("Client with IP : " + cl.getIPAddress() + " has sent a request to server : \t" + info);
System.out.println("Response sent to IP : \t" + cl.getIPAddress());
cl.acknoledgeConfirmation();
break;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
if(i == 10)
System.out.println("Response not sent");
}
}