-
Notifications
You must be signed in to change notification settings - Fork 0
/
ReceiveThread.pde
44 lines (38 loc) · 1.21 KB
/
ReceiveThread.pde
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
public class ReceiveThread implements Runnable {
public void run()
{
try {
/*
Socket socket = new Socket("192.168.1.68", 31946);
InputStream in = socket.getInputStream();
StringBuilder stringaJson = new StringBuilder();
InputStreamReader reader = new InputStreamReader(in, "ASCII");
for (int c = reader.read (); c != -1; c = reader.read()) {
stringaJson.append((char) c);
}
println(stringaJson);
String blabla= stringaJson.toString();
*/
String lines[] = loadStrings("http://thebit.altervista.org/spaceapps/getValues.php?id_astronauta=2");
for(String s : lines)
{
println(s);
}
JSONObject json = JSONObject.parse(lines[0]);
JSONArray listaJson= json.getJSONArray("astronauts");
for (int i=0; i<listaJson.size (); i++)
{
JSONObject j = listaJson.getJSONObject(i);
Astronaut a = getAstronautFromID(j.getInt("id"));
a.setph_saliva(j.getFloat("ph_saliva"));
a.setTemperature(j.getFloat("temperature"));
a.setph_gas(j.getFloat("ph_gas"));
}
//socket.close();
}
catch(Exception e)
{
println("asdhhh");
}
}
}