-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.pde
44 lines (38 loc) · 987 Bytes
/
client.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
String name="ra";
SensorReading actualRequest = null;
SensorReading nextRequest = null;
boolean readingDone=true;
void setupClient() {
oscP5 = new OscP5(this, port);
// connect msg
OscMessage m = new OscMessage("/connect");
m.add(name);
oscP5.send(m, serverLocation);
}
void client_update() {
if (actualRequest!=null && !readingDone) {
actualRequest.execute();
}
}
void client_oscEvent(OscMessage msg) {
String sensorName = msg.get(0).stringValue();
if (msg.addrPattern().equals("/request")) {
if (readingDone) {
actualRequest = sensors.get(sensorName);
readingDone = false;
actualRequest.init();
}
else {
nextRequest= sensors.get(sensorName);
}
}
else if (msg.addrPattern().equals("/result")) {
SensorReading sr = sensors.get(sensorName);
sr = sr.createFromMessage(msg);
sr.print();
}
}
void sendDisconnect() {
OscMessage m = new OscMessage("/disconnect");
oscP5.send(m, serverLocation);
}