@@ -220,48 +220,6 @@ protected String getLogStart() {
220220 return this .getClass ().getSimpleName ();
221221 }
222222
223- /////////////////////////////////////////////////////////////////////////////////////
224- // ASAP hub management //
225- /////////////////////////////////////////////////////////////////////////////////////
226-
227- /**
228- * Call this message to connect to a hub via tcp
229- */
230- public void connectTCPHub (CharSequence hostName , int port ) {
231- Log .d (this .getLogStart (), "send message to service: connect hub via tcp: "
232- + hostName + ":" + port );
233-
234- try {
235- Message connectHubMessage = MessageFactory .createConnectHubMessage (
236- HubConnectorFactory .createTCPConnectorDescription (hostName , port ));
237-
238- this .sendMessage2Service (connectHubMessage );
239-
240- } catch (IOException e ) {
241- Log .e (this .getLogStart (), "cannot create hub connect message: "
242- + e .getLocalizedMessage ());
243- }
244- }
245-
246- /**
247- * Call this message to disconnect to a hub via tcp
248- */
249- public void disconnectTCPHub (CharSequence hostName , int port ) {
250- Log .d (this .getLogStart (), "send message to service: disconnect from hub via tcp: "
251- + hostName + ":" + port );
252-
253- try {
254- Message connectHubMessage = MessageFactory .createDisconnectHubMessage (
255- HubConnectorFactory .createTCPConnectorDescription (hostName , port ));
256-
257- this .sendMessage2Service (connectHubMessage );
258-
259- } catch (IOException e ) {
260- Log .e (this .getLogStart (), "cannot create hub disconnect message: "
261- + e .getLocalizedMessage ());
262- }
263- }
264-
265223 /////////////////////////////////////////////////////////////////////////////////////
266224 // mac protocol stuff //
267225 /////////////////////////////////////////////////////////////////////////////////////
@@ -343,6 +301,31 @@ public void startBluetoothDiscovery() {
343301 this .sendMessage2Service (ASAPServiceMethods .START_BLUETOOTH_DISCOVERY );
344302 }
345303
304+ /////////////////////////////////////////////////////////////////////////////////////
305+ // ASAP hub management //
306+ /////////////////////////////////////////////////////////////////////////////////////
307+
308+ /**
309+ * Call this message to connect all known hubs and run encounter attempts in regular intervals.
310+ */
311+ public void connectASAPHubs () {
312+ Log .d (this .getLogStart (), "send message to service: start ASAP hubs" );
313+ this .sendMessage2Service (ASAPServiceMethods .CONNECT_ASAP_HUBS );
314+ }
315+
316+ /**
317+ * Call this message to connect cancel all hub connections. Your app will be back in
318+ * Ad-hoc communication only mode.
319+ */
320+ public void disconnectASAPHubs () {
321+ Log .d (this .getLogStart (), "send message to service: stop ASAP hubs" );
322+ this .sendMessage2Service (ASAPServiceMethods .DISCONNECT_ASAP_HUBS );
323+ }
324+
325+ /////////////////////////////////////////////////////////////////////////////////////
326+ // manage broadcast with service //
327+ /////////////////////////////////////////////////////////////////////////////////////
328+
346329 /*
347330 There is a race condition:
348331 ASAPActivity a can launch ASAPActivity b. It happens (quite often actually) that a.onStop()
@@ -632,6 +615,16 @@ public void asapNotifyOnlinePeersChanged(Set<CharSequence> peerList) {
632615 this .getASAPAndroidPeer ().notifyOnlinePeersChanged (peerList );
633616 }
634617
618+ @ Override
619+ public void asapNotifyHubsConnected () {
620+ this .getASAPAndroidPeer ().notifyASAPHubsConnected (true );
621+ }
622+
623+ @ Override
624+ public void asapNotifyHubsDisconnected () {
625+ this .getASAPAndroidPeer ().notifyASAPHubsConnected (false );
626+ }
627+
635628 /**
636629 * Application developers can use this method like life-cycle methods in Android
637630 * (onStart() etc.). Overwrite this method to get informed about changes in environment.
@@ -684,4 +677,6 @@ public boolean isBluetoothDiscoverable() {
684677 public boolean isBluetoothDiscovery () {
685678 return this .getASAPAndroidPeer ().getBTDiscovery ();
686679 }
680+
681+ public boolean isASAPHubsConnected () { return this .getASAPAndroidPeer ().getASAPHubsConnected (); }
687682}
0 commit comments