}
// Game time
-
private boolean configured = false;
- private long startT; // NTP seconds for game start
+ private long startT; // POSIX seconds for game start
private int setupD;
private int rounds;
private int roundD;
private int gameIx;
- private long endT = 0; // NTP seconds for game end (if >= startT)
+ private long endT = 0; // POSIX seconds for game end (if >= startT)
public void fromMqttConfigMessage(String st) {
String tm = st.trim();
}
// Game score
-
public int flagsTotal;
public boolean flagsVisible = false;
public int flagsRed = 0;
public int flagsYel = 0;
-
public void fromMqttFlagsMessage(String st) {
String tm = st.trim();
switch(tm) {
}
// Informative messages handling
-
public class Msg {
public final long when;
public final String msg;
}
private final List<Msg> msgs = new ArrayList<>();
private long lastMsgTimestamp;
-
public void onNewMessage(String str) {
Scanner s = new Scanner(str);
long t;
}
// Observer interface
-
public interface Observer {
// Called when the game configuration parameters change
void onCtFwSConfigure(CtFwSGameState game);
@Override
public void connectComplete(boolean reconnect, String serverURI) {
Log.d("CtFwS", "Conn OK 2 srv=" + serverURI + " reconn=" + reconnect);
+ String p = "ctfws/game/";
try {
- String p = "ctfws/game/";
- mMqc.subscribe(p+"config" , 2, null, subal, mCtfwscbs.onConfig);
- mMqc.subscribe(p+"endtime" , 2, null, subal, mCtfwscbs.onEnd);
- mMqc.subscribe(p+"flags" , 2, null, subal, mCtfwscbs.onFlags);
- mMqc.subscribe(p+"message" , 2, null, subal, mCtfwscbs.onMessage);
- mMqc.subscribe(p+"message/player", 2, null, subal, mCtfwscbs.onPlayerMessage);
- setMSE(MqttServerEvent.MSE_SUB);
+ mMqc.subscribe(p + "config", 2, null, subal, mCtfwscbs.onConfig);
+ mMqc.subscribe(p + "endtime", 2, null, subal, mCtfwscbs.onEnd);
+ mMqc.subscribe(p + "flags", 2, null, subal, mCtfwscbs.onFlags);
+ mMqc.subscribe(p + "message", 2, null, subal, mCtfwscbs.onMessage);
+ mMqc.subscribe(p + "message/player", 2, null, subal, mCtfwscbs.onPlayerMessage);
} catch (MqttException e) {
Log.e("CtFwS", "Exn Sub", e);
}
+ setMSE(MqttServerEvent.MSE_SUB);
}
@Override
// Ahem. Now then. Connect with *more callbacks*, which will fire off our
// subscription requests, which of course have *yet more* callbacks, which
// react to messages sent to us. Have we lost the thread yet?
+ MqttConnectOptions mco = new MqttConnectOptions();
+ mco.setCleanSession(true);
+ mco.setAutomaticReconnect(true);
+ mco.setKeepAliveInterval(180); // seconds
try {
- MqttConnectOptions mco = new MqttConnectOptions();
- mco.setCleanSession(true);
- mco.setAutomaticReconnect(true);
- mco.setKeepAliveInterval(180); // seconds
mMqc.connect(mco, null, mqttal);
- Log.d("Service", "Connect dispatched");
} catch (MqttException e) {
Log.e("Service", "Conn Exn", e);
}
+ Log.d("Service", "Connect dispatched");
}
// Must hold strongly since Android only holds weakly once registered.