@@ -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}
0 commit comments