- Timestamp:
- 07/06/13 03:51:11 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/communication/Subscription.java
r96 r97 4 4 5 5 import com.framsticks.communication.queries.RegistrationRequest; 6 import com.framsticks.util.dispatching.AtOnceDispatcher; 6 7 import com.framsticks.util.dispatching.Dispatcher; 7 8 import com.framsticks.util.dispatching.Dispatching; 8 9 import com.framsticks.util.dispatching.RunAt; 9 import com.framsticks.util. FramsticksException;10 import com.framsticks.util.StateFunctor; 10 import com.framsticks.util.dispatching.ThrowExceptionHandler; 11 11 12 import org.apache.log4j.Logger; 12 13 … … 19 20 private final static Logger log = Logger.getLogger(Subscription.class); 20 21 21 private final Client Connection connection;22 private final ClientSideManagedConnection connection; 22 23 private final String path; 23 24 private final String registeredPath; … … 26 27 private EventCallback eventCallback; 27 28 28 public Subscription(Client Connection connection, String path, String registeredPath, Dispatcher<C> dispatcher) {29 public Subscription(ClientSideManagedConnection connection, String path, String registeredPath, Dispatcher<C> dispatcher) { 29 30 this.connection = connection; 30 31 this.path = path; … … 46 47 } 47 48 48 public void unsubscribe(final StateFunctor stateFunctor) {49 public void unsubscribe(final ClientSideResponseFuture future) { 49 50 //@todo remove that /cli/ prefix, when registeredPath will be a fully qualified path 50 connection.send(new RegistrationRequest().register(false).path(registeredPath), new ResponseCallback<Connection>() { 51 connection.send(new RegistrationRequest().register(false).path(registeredPath), AtOnceDispatcher.getInstance(), new ClientSideResponseFuture(future) { 52 51 53 @Override 52 public void process(Response response) { 53 if (!response.getOk()) { 54 log.error("failed to unsunscribe " + this + ": " + response.getComment()); 55 stateFunctor.handle(new FramsticksException().msg("unsubscription failed").arg("comment", response.getComment())); 56 return; 57 } 54 protected void processOk(Response response) { 58 55 assert response.hasFiles(); 59 56 log.debug("unsunscribed " + this); 60 stateFunctor.call();57 future.pass(response); 61 58 } 62 59 }); … … 76 73 77 74 public void dispatchCall(final List<File> files) { 78 Dispatching.dispatchIfNotActive(dispatcher, new RunAt<C>() { 75 //TODO TEH 76 Dispatching.dispatchIfNotActive(dispatcher, new RunAt<C>(ThrowExceptionHandler.getInstance()) { 79 77 @Override 80 p ublic void run() {78 protected void runAt() { 81 79 eventCallback.call(files); 82 80 }
Note: See TracChangeset
for help on using the changeset viewer.