summaryrefslogtreecommitdiff
path: root/same-android/src/main/java/com/orbekk/same/SameService.java
diff options
context:
space:
mode:
authorKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-25 23:02:13 +0100
committerKjetil Ørbekk <kjetil.orbekk@gmail.com>2012-02-25 23:02:18 +0100
commitdf19ffa05ec5dfc6bccb010bc9fd6231987bafcb (patch)
tree2825961568875dac94091c2bef2444fdf24cdc27 /same-android/src/main/java/com/orbekk/same/SameService.java
parent232b46f11e0249cad574e35bd2e0d5922efa7d6f (diff)
SameService sends all state initially to new listeners.
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.java16
1 files changed, 16 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 55fb17c..dad4b50 100644
--- a/same-android/src/main/java/com/orbekk/same/SameService.java
+++ b/same-android/src/main/java/com/orbekk/same/SameService.java
@@ -97,6 +97,7 @@ public class SameService extends Service {
Messenger messenger = message.replyTo;
if (messenger != null) {
stateReceivers.add(messenger);
+ sendAllState(messenger);
} else {
logger.error("ADD_STATE_RECEIVER: Missing Messenger.");
}
@@ -127,6 +128,21 @@ public class SameService extends Service {
}
};
+ private void sendAllState(Messenger messenger) {
+ State state = sameController.getClient().getInterface().getState();
+ for (Component c : state.getComponents()) {
+ Message message = Message.obtain(null, UPDATED_STATE_MESSAGE);
+ message.obj = c;
+ try {
+ messenger.send(message);
+ } catch (RemoteException e) {
+ logger.warn("Failed to send state.");
+ e.printStackTrace();
+ return;
+ }
+ }
+ }
+
private void initializeConfiguration() {
Properties properties = new Properties();
String localIp = new Broadcaster(this)