-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNetworkCycle.java
More file actions
84 lines (74 loc) · 2.03 KB
/
NetworkCycle.java
File metadata and controls
84 lines (74 loc) · 2.03 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import java.util.ArrayList;
import processing.core.PApplet;
/***
class used to cycle between a list of networks by logging in automatically
**/
class NetworkCycle extends Thread
{
private ObjectProvider objects;
private ObjectUpdater updater;
private DAL server;
private PApplet context;
private String[] networks;
private int networkDelay;
private long lastCall;
private int current;
NetworkCycle(PApplet context, ObjectProvider objects, ObjectUpdater updater, String networks, int networkDelay)
{
this.objects = objects;
this.updater = updater;
this.server = objects.getDALServer();
this.context = context;
this.networks = this.parseNetworks(networks);
this.networkDelay = networkDelay;
this.current = 1;
this.readTime();
}
public void run()
{
while (true) {
try {
Thread.sleep(this.networkDelay);
} catch (InterruptedException x) {
break;
}
//this.updater.freeze();
String [] currentNetwork = this.context.split(this.networks[this.current], ",");
String login = currentNetwork[0];
String password = currentNetwork[1];
if(this.objects.getDAL().login(login, password))
{
System.out.println("logged in successfully.");
this.objects.resetGlobalFader();
this.objects.getUsersFirstBrainstorm();
}
else
{
System.out.println("Error logging in automatically.");
}
if (this.current < this.networks.length-1)
{
System.out.println("There are still networks, incrementing current network.");
this.current++;
//this.updater.unfreeze();
}
else
{
System.out.println("Showed all networks, resetting to the first one");
this.current = 0;
}
}
}
public String[] parseNetworks(String networks)
{
return this.context.split(networks,";");
}
public void readTime()
{
this.lastCall = server.getCurrentTime();
}
public void setTime(long time)
{
lastCall = time;
}
}