@Override public synchronized long subscribe(String regex, SubscriberCallback client) throws RemoteException { regex = regex.replaceAll("'", ""); Subscription s = new Subscription(regex, client); subscriptions.add(s); return s.getId(); }
@Override public synchronized void unsubscribe(long id) throws RemoteException { for (Subscription sub : subscriptions) { if (sub.getId() == id) { subscriptions.remove(sub); break; } } }
public synchronized void killSubscriptions() { System.out.println("kill subs..."); for (Subscription sub : subscriptions) { try { System.out.println("subID: " + sub.getId() + "..."); sub.getClient().terminate(); System.out.println("\t...removed"); } catch (RemoteException e) { System.out.println("..remove error"); // e.printStackTrace(); } } }