Enable “WatchGlobal” mode directly after connecting.
[jFCPlib.git] / src / net / pterodactylus / fcp / highlevel / FcpClient.java
index dae7546..aa2c8f1 100644 (file)
@@ -165,6 +165,8 @@ public class FcpClient {
                                fcpConnection.connect();
                                ClientHello clientHello = new ClientHello(name);
                                fcpConnection.sendMessage(clientHello);
+                               WatchGlobal watchGlobal = new WatchGlobal(true);
+                               fcpConnection.sendMessage(watchGlobal);
                        }
 
                        /**
@@ -565,7 +567,6 @@ public class FcpClient {
                        @Override
                        @SuppressWarnings("synthetic-access")
                        public void run() throws IOException {
-                               fcpConnection.sendMessage(new WatchGlobal(global));
                                fcpConnection.sendMessage(new ListPersistentRequests());
                        }
 
@@ -574,7 +575,9 @@ public class FcpClient {
                         */
                        @Override
                        public void receivedPersistentGet(FcpConnection fcpConnection, PersistentGet persistentGet) {
-                               getRequests.add(persistentGet);
+                               if (!persistentGet.isGlobal() || global) {
+                                       getRequests.add(persistentGet);
+                               }
                        }
 
                        /**