Skip to content

Commit fee9341

Browse files
committed
was working on that sync problem in ASAPhub
1 parent 75a903b commit fee9341

19 files changed

+41
-55
lines changed

.idea/artifacts/ASAPJava_jar.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

META-INF/MANIFEST.MF

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
Manifest-Version: 1.0
2+
Main-Class: net.sharksystem.asap.cmdline.CmdLineUI
23

manifest.mf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
Manifest-Version: 1.0
22
X-COMMENT: Main-Class will be added automatically by build
3-
Main-Class: net.sharksystem.cmdline.CmdLineUI
3+
Main-Class: net.sharksystem.asap.cmdline.CmdLineUI
44

src/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Manifest-Version: 1.0
2-
Main-Class: net.sharksystem.cmdline.CmdLineUI
2+
Main-Class: net.sharksystem.asap.cmdline.CmdLineUI
33

src/net/sharksystem/asap/ASAPEncounterManagerImpl.java

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ private boolean coolDownOver(CharSequence id, EncounterConnectionType connection
5757
Date lastEncounter = this.encounterDate.get(id);
5858

5959
if(lastEncounter == null) {
60-
Log.writeLog(this, "device/peer not in encounteredDevices - should connect");
60+
Log.writeLog(this, this.toString(), "device/peer not in encounteredDevices - should connect");
6161
this.encounterDate.put(id, now);
6262
return true;
6363
}
@@ -69,20 +69,20 @@ private boolean coolDownOver(CharSequence id, EncounterConnectionType connection
6969
long reconnectedBeforeInMillis = nowInMillis - this.waitBeforeReconnect;
7070
Date reconnectBefore = new Date(reconnectedBeforeInMillis);
7171

72-
Log.writeLog(this, "now: " + now.toString());
73-
Log.writeLog(this, "connectBefore: " + reconnectBefore.toString());
72+
Log.writeLog(this, this.toString(), "now: " + now.toString());
73+
Log.writeLog(this, this.toString(), "connectBefore: " + reconnectBefore.toString());
7474

7575
// known peer
76-
Log.writeLog(this, "device/peer (" + id + ") in encounteredDevices list?");
76+
Log.writeLog(this, this.toString(), "device/peer (" + id + ") in encounteredDevices list?");
7777
// it was in the list
7878
if(lastEncounter.before(reconnectBefore)) {
79-
Log.writeLog(this, "yes - should connect: " + id);
79+
Log.writeLog(this, this.toString(), "yes - should connect: " + id);
8080
// remember that and overwrite previous entry
8181
this.encounterDate.put(id, now);
8282
return true;
8383
}
8484

85-
Log.writeLog(this, "should not connect - recently met: " + id);
85+
Log.writeLog(this, this.toString(), "should not connect - recently met: " + id);
8686
return false;
8787
}
8888

@@ -134,7 +134,7 @@ private void handleEncounter(StreamPair streamPair, EncounterConnectionType conn
134134

135135
CharSequence streamPairID = streamPair.getSessionID();
136136

137-
Log.writeLog(this, "socket called: handle new encounter" + streamPair);
137+
Log.writeLog(this, this.toString(), "socket called: handle new encounter" + streamPair);
138138

139139
// should we connect in the first place
140140
if (!this.shouldCreateConnectionToPeer(streamPairID, connectionType)) {
@@ -161,13 +161,13 @@ private void handleEncounter(StreamPair streamPair, EncounterConnectionType conn
161161
}
162162

163163
// we a through with it - remember that new stream pair
164-
Log.writeLog(this, "remember streamPair: " + streamPair);
164+
Log.writeLog(this, this.toString(), "remember streamPair: " + streamPair);
165165
this.openStreamPairs.put(streamPairID, streamPair);
166166

167-
Log.writeLog(this, "going to launch a new asap connection");
167+
Log.writeLog(this, this.toString(), "going to launch a new asap connection");
168168

169169
try {
170-
Log.writeLog(this, "call asap peer to handle connection");
170+
Log.writeLog(this, this.toString(), "call asap peer to handle connection");
171171
ASAPConnection asapConnection =
172172
this.asapConnectionHandler.handleConnection(
173173
streamPair.getInputStream(), streamPair.getOutputStream(), connectionType);
@@ -177,7 +177,8 @@ private void handleEncounter(StreamPair streamPair, EncounterConnectionType conn
177177
this.openASAPConnections.put(asapConnection, streamPairID);
178178

179179
} catch (IOException | ASAPException e) {
180-
Log.writeLog(this, "while launching asap connection: " + e.getLocalizedMessage());
180+
Log.writeLog(this, this.toString(), "while launching asap connection: "
181+
+ e.getLocalizedMessage());
181182
}
182183
}
183184

@@ -218,7 +219,7 @@ private boolean waitBeforeASAPSessionLaunch(InputStream is, OutputStream os, boo
218219
sb.append(initiatorValue);
219220
sb.append(" | nonInitiatorValue == ");
220221
sb.append(nonInitiatorValue);
221-
Log.writeLog(this, sb.toString());
222+
Log.writeLog(this, this.toString(), sb.toString());
222223

223224
/* Here comes the bias: An initiator with a smaller value waits a moment */
224225
if(connectionInitiator && initiatorValue < nonInitiatorValue) {
@@ -227,11 +228,11 @@ private boolean waitBeforeASAPSessionLaunch(InputStream is, OutputStream os, boo
227228
sb.append("wait ");
228229
sb.append(waitInMillis);
229230
sb.append(" ms");
230-
Log.writeLog(this, sb.toString());
231+
Log.writeLog(this, this.toString(), sb.toString());
231232
Thread.sleep(waitInMillis);
232233
return true; // waited
233234
} catch (InterruptedException e) {
234-
Log.writeLog(this, "wait interrupted");
235+
Log.writeLog(this, this.toString(), "wait interrupted");
235236
}
236237
}
237238

@@ -245,7 +246,7 @@ private boolean waitBeforeASAPSessionLaunch(InputStream is, OutputStream os, boo
245246
@Override
246247
public synchronized void asapConnectionStarted(String remotePeerName, ASAPConnection connection) {
247248
CharSequence peerID = connection.getEncounteredPeer();
248-
Log.writeLog(this, "new ASAP session started with peerID " + peerID);
249+
Log.writeLog(this, this.toString(), "new ASAP session started with peerID " + peerID);
249250

250251
CharSequence streamPairID = this.openASAPConnections.get(connection);
251252
if(PeerIDHelper.sameID(streamPairID, peerID)) {
@@ -294,4 +295,8 @@ public synchronized void asapConnectionTerminated(Exception terminatingException
294295
}
295296
}
296297
}
298+
299+
public String toString() {
300+
return this.asapConnectionHandler.toString();
301+
}
297302
}

src/net/sharksystem/asap/apps/gossip/GossipUI.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
import net.sharksystem.asap.ASAPMessages;
66
import net.sharksystem.asap.engine.*;
77
import net.sharksystem.asap.utils.Helper;
8-
import net.sharksystem.cmdline.TCPStream;
9-
import net.sharksystem.cmdline.TCPStreamCreatedListener;
8+
import net.sharksystem.asap.cmdline.TCPStream;
9+
import net.sharksystem.asap.cmdline.TCPStreamCreatedListener;
1010

1111
import java.io.IOException;
1212
import java.text.DateFormat;

src/net/sharksystem/cmdline/CmdLineUI.java renamed to src/net/sharksystem/asap/cmdline/CmdLineUI.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.sharksystem.cmdline;
1+
package net.sharksystem.asap.cmdline;
22

33
import net.sharksystem.asap.ASAPChannel;
44
import net.sharksystem.asap.ASAPException;

src/net/sharksystem/cmdline/ExampleASAPChunkReceivedListener.java renamed to src/net/sharksystem/asap/cmdline/ExampleASAPChunkReceivedListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.sharksystem.cmdline;
1+
package net.sharksystem.asap.cmdline;
22

33
import net.sharksystem.asap.ASAPHop;
44
import net.sharksystem.asap.engine.ASAPChunkReceivedListener;

src/net/sharksystem/cmdline/TCPASAPPeerFS.java renamed to src/net/sharksystem/asap/cmdline/TCPASAPPeerFS.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.sharksystem.cmdline;
1+
package net.sharksystem.asap.cmdline;
22

33
/**
44
* Run an ASAP peer that can communicate with TCP. It can offer an open tcp server socket.

src/net/sharksystem/cmdline/TCPStream.java renamed to src/net/sharksystem/asap/cmdline/TCPStream.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package net.sharksystem.cmdline;
1+
package net.sharksystem.asap.cmdline;
22

33
import java.io.IOException;
44
import java.io.InputStream;

0 commit comments

Comments
 (0)