diff options
author | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-25 22:52:52 +0100 |
---|---|---|
committer | Kjetil Ørbekk <kjetil.orbekk@gmail.com> | 2012-02-25 22:52:52 +0100 |
commit | 05383f1ba3298c20c97a3976ed303016c3a6e9f3 (patch) | |
tree | fa7a9298ddf77329ae754038f0b080fae229ec19 /same-android/src/main/java/com/orbekk/same/SameService.java | |
parent | bfa3a4fad59027e64cf6a4667d29b3f069859954 (diff) |
Send messages correctly.
Diffstat (limited to 'same-android/src/main/java/com/orbekk/same/SameService.java')
-rw-r--r-- | same-android/src/main/java/com/orbekk/same/SameService.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/same-android/src/main/java/com/orbekk/same/SameService.java b/same-android/src/main/java/com/orbekk/same/SameService.java index 53742bd..55fb17c 100644 --- a/same-android/src/main/java/com/orbekk/same/SameService.java +++ b/same-android/src/main/java/com/orbekk/same/SameService.java @@ -111,10 +111,19 @@ public class SameService extends Service { private StateChangedListener stateListener = new StateChangedListener() { @Override public void stateChanged(Component component) { + ArrayList<Messenger> dropped = new ArrayList<Messenger>(); for (Messenger messenger : stateReceivers) { Message message = Message.obtain(null, UPDATED_STATE_MESSAGE); message.obj = component; + try { + messenger.send(message); + } catch (RemoteException e) { + logger.warn("Failed to send update. Dropping state receiver."); + e.printStackTrace(); + dropped.add(messenger); + } } + stateReceivers.removeAll(dropped); } }; @@ -168,6 +177,8 @@ public class SameService extends Service { try { sameController.start(); sameController.getClient().setNetworkListener(networkListener); + sameController.getClient().getInterface() + .addStateListener(stateListener); } catch (Exception e) { logger.error("Failed to start server", e); } |