Skip to content

Commit e3eacd6

Browse files
committed
connecting to multiple hub available on API
1 parent 2d1a21e commit e3eacd6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/main/java/net/sharksystem/hub/HubConnectionManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public interface HubConnectionManager extends NewHubConnectionListenerManagement
2222
*/
2323
void connectHub(HubConnectorDescription hcd) throws SharkException, IOException;
2424

25+
void connectHubs(List<HubConnectorDescription> hcdList) throws SharkException, IOException;
26+
2527
/**
2628
* Disconnect from a hub
2729
* @param hcd description

src/main/java/net/sharksystem/hub/HubConnectionManagerImpl.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import net.sharksystem.hub.peerside.HubConnectorDescription;
99

1010
import java.io.IOException;
11+
import java.util.List;
1112

1213
/**
1314
* That class merges encounter and asap hub management
@@ -25,6 +26,15 @@ protected void syncLists() {
2526
super.syncLists();
2627
}
2728

29+
public void connectHubs(List<HubConnectorDescription> hcdList) throws SharkException, IOException {
30+
if(hcdList == null || hcdList.isEmpty()) return;
31+
this.syncLists();
32+
for(HubConnectorDescription hcd : hcdList) {
33+
super.connectHub(hcd);
34+
}
35+
this.connectionChanged(true);
36+
}
37+
2838
public void connectHub(HubConnectorDescription hcd) throws SharkException, IOException {
2939
this.syncLists();
3040
super.connectHub(hcd);
@@ -74,12 +84,18 @@ public void stopThreads() {
7484
this.hubManager.kill();
7585
}
7686

87+
/* this first parameter hcd is useless ?? */
7788
@Override
7889
public void connectionChanged(HubConnectorDescription hcd, boolean connect) {
7990
// list are already in order - tell hub manager
8091
this.hubManager.connectASAPHubs(this.hcdList, this.asapPeer, true);
8192
}
8293

94+
public void connectionChanged(boolean connect) {
95+
// list are already in order - tell hub manager
96+
this.hubManager.connectASAPHubs(this.hcdList, this.asapPeer, true);
97+
}
98+
8399
@Override
84100
public void refreshHubList() {
85101
// ask hub manager for a fresh list

0 commit comments

Comments
 (0)