Skip to content

Commit 75a903b

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

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/net/sharksystem/asap/utils/ASAPSerialization.java

+3
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ public static String printBitsToString(long l, int bits) {
173173
public static String printByteArrayToString(byte[] byteArray) {
174174
StringBuilder sb = new StringBuilder();
175175
for(int index = byteArray.length - 1; index >= 0; index--) {
176+
sb.append("[");
177+
sb.append(index);
178+
sb.append("]: ");
176179
sb.append(printByteToString(byteArray[index]));
177180
}
178181
return sb.toString();

src/net/sharksystem/streams/StreamPairLink.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ public class StreamPairLink implements StreamPairListener {
99
private StreamLink streamLinkB2A;
1010

1111
public StreamPairLink(StreamPair pairA, CharSequence idA, StreamPair pairB, CharSequence idB) throws IOException {
12+
this(pairA, idA, pairB, idB, true);
13+
}
14+
15+
public StreamPairLink(
16+
StreamPair pairA, CharSequence idA,
17+
StreamPair pairB, CharSequence idB,
18+
boolean autostart) throws IOException {
1219
String tagA2B = idB + " ==> " + idA;
1320
this.streamLinkA2B = new StreamLink(pairA.getInputStream(), pairB.getOutputStream(), true, tagA2B);
1421
String tagB2A = idA + " ==> " + idB;
@@ -18,8 +25,7 @@ public StreamPairLink(StreamPair pairA, CharSequence idA, StreamPair pairB, Char
1825
pairA.addListener(this);
1926
pairB.addListener(this);
2027

21-
this.streamLinkA2B.start();
22-
this.streamLinkB2A.start();
28+
if(autostart) this.start();
2329
}
2430

2531
@Override
@@ -28,4 +34,9 @@ public void notifyClosed(StreamPair closedStreamPair, String key) {
2834
this.streamLinkA2B.close();
2935
this.streamLinkB2A.close();
3036
}
37+
38+
public void start() {
39+
this.streamLinkA2B.start();
40+
this.streamLinkB2A.start();
41+
}
3142
}

0 commit comments

Comments
 (0)