diff options
author | Andrzej J.R. Hunt <andrzej@ahunt.org> | 2012-08-03 10:29:09 +0200 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-08-06 10:23:09 +0100 |
commit | cb82805c524e2d65ad75221bb50eee808c4177c8 (patch) | |
tree | 0964368dca020d8400ddbb47c96e99c58d62b958 | |
parent | 3213339132be43ce8ca502924c741cfac53ed09e (diff) |
Server discovery broadcast.
Change-Id: I10f0ac295ea14128908a87f4ef6a4c4524e76262
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java | 4 | ||||
-rw-r--r-- | android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java | 14 |
2 files changed, 15 insertions, 3 deletions
diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java index 432946042b96..a278e9d9c6e6 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/CommunicationService.java @@ -36,13 +36,15 @@ public class CommunicationService extends Service { public static final int MSG_SLIDE_PREVIEW = 3; public static final int MSG_SLIDE_NOTES = 4; + public static final String MSG_SERVERLIST_CHANGED = "SERVERLIST_CHANGED"; + private Transmitter mTransmitter; private Client mClient; private Receiver mReceiver = new Receiver(); - private ServerFinder mFinder = new ServerFinder(); + private ServerFinder mFinder = new ServerFinder(this); public void setActivityMessenger(Messenger aActivityMessenger) { mReceiver.setActivityMessenger(aActivityMessenger); diff --git a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java index 768eba599adb..b8ba315c4f76 100644 --- a/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java +++ b/android/sdremote/src/org/libreoffice/impressremote/communication/ServerFinder.java @@ -10,8 +10,14 @@ import java.util.Vector; import org.libreoffice.impressremote.communication.CommunicationService.Server; +import android.content.Context; +import android.content.Intent; +import android.support.v4.content.LocalBroadcastManager; + public class ServerFinder { + private Context mContext; + private static final int PORT = 1598; private static final String CHARSET = "UTF-8"; @@ -23,8 +29,8 @@ public class ServerFinder { private Vector<Server> mServerList = new Vector<Server>(); - public ServerFinder() { - + public ServerFinder(Context aContext) { + mContext = aContext; } private void listenForServer() { @@ -52,6 +58,10 @@ public class ServerFinder { System.currentTimeMillis()); mServerList.add(aServer); + Intent aIntent = new Intent( + CommunicationService.MSG_SERVERLIST_CHANGED); + LocalBroadcastManager.getInstance(mContext).sendBroadcast(aIntent); + } catch (java.net.SocketTimeoutException e) { // Ignore -- we want to timeout to enable checking whether we // should stop listening periodically |