diff options
| author | Paul Buetow <paul@buetow.org> | 2008-05-17 15:55:43 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2008-05-17 15:55:43 +0000 |
| commit | 30ac208bac5acb677b2359a3f21f028b5b10a2b3 (patch) | |
| tree | 1683f593e92fddf99303726d505e5d4d77bc5c4b /sources/protocols/InternalTimeSyncProtocol.java | |
| parent | 269558d30023525012a3b0633b030fa2e9151e29 (diff) | |
renamed the package.
Diffstat (limited to 'sources/protocols/InternalTimeSyncProtocol.java')
| -rw-r--r-- | sources/protocols/InternalTimeSyncProtocol.java | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/sources/protocols/InternalTimeSyncProtocol.java b/sources/protocols/InternalTimeSyncProtocol.java deleted file mode 100644 index 961cf65..0000000 --- a/sources/protocols/InternalTimeSyncProtocol.java +++ /dev/null @@ -1,69 +0,0 @@ -package protocols; - -import prefs.VSPrefs; -import core.VSMessage; - -public class InternalTimeSyncProtocol extends VSProtocol { - private boolean waitingForResponse; - - protected void onInit() { - setProtocolClassname(getClass().toString()); - - /* Those prefs are editable through the VSProtocol VSEditor GUI. t_min and t_max in milliseconds */ - setLong("t_min", 1000); - setLong("t_max", 5000); - } - - protected void onClientReset() { - } - - protected void onClientStart() { - waitingForResponse = true; - - /* Multicast message to all processes */ - VSMessage message = new VSMessage(getProtocolClassname()); - message.setBoolean("isClientRequest", true); - sendMessage(message); - } - - protected void onClientRecv(VSMessage recvMessage) { - /* Ignore all protocol messages which are not a response message, e.g. itself */ - if (!recvMessage.getBoolean("isServerResponse")) - return; - - if (waitingForResponse) - waitingForResponse = false; - else - return; - - long tMax = getLong("t_max"); - long tMin = getLong("t_min"); - long serverTime = recvMessage.getLong("time"); - long newTime = serverTime + (long) ((tMax + tMin) / 2 ); - - logg("Server Zeit: " + serverTime + "; (t_min,t_max): (" + tMin + "," + tMax - + "); Alte Zeit: " + process.getTime() + "; Neue Zeit: " + newTime - + "; Offset: " + (process.getTime() - newTime)); - - process.setTime(newTime); - } - - protected void onServerReset() { - } - - protected void onServerRecv(VSMessage recvMessage) { - /* Ignore all protocol messages which are not a request message, e.g. itself */ - if (!recvMessage.getBoolean("isClientRequest")) - return; - - /* Multicast message to all processes */ - VSMessage message = new VSMessage(getProtocolClassname()); - message.setLong("time", process.getTime()); - message.setBoolean("isServerResponse", true); - sendMessage(message); - } - - public String toString() { - return super.toString(); - } -} |
