use of it.unibo.arces.wot.sepa.commons.response.UnsubscribeResponse in project SEPA by arces-wot.
the class SPUManager method unsubscribe.
public Response unsubscribe(UnsubscribeRequest req) {
logger.debug(req);
SPUManagerBeans.unsubscribeRequest();
String spuid = req.getSubscribeUUID();
if (!spus.containsKey(spuid))
return new ErrorResponse(req.getToken(), 404, "SPUID not found: " + spuid);
synchronized (unsubscribeQueue) {
unsubscribeQueue.offer(spus.get(spuid));
unsubscribeQueue.notify();
}
return new UnsubscribeResponse(req.getToken(), spuid);
}
use of it.unibo.arces.wot.sepa.commons.response.UnsubscribeResponse in project SEPA by arces-wot.
the class SEPAWebsocketClient method onMessage.
@Override
public void onMessage(String message) {
logger.debug("@onMessage " + message);
// Parse message
JsonObject notify = new JsonParser().parse(message).getAsJsonObject();
if (notify.get("ping") != null) {
if (handler != null)
handler.onPing();
} else if (notify.get("subscribed") != null) {
response = new SubscribeResponse(notify);
setResponse();
} else if (notify.get("unsubscribed") != null) {
response = new UnsubscribeResponse(notify);
setResponse();
} else if (notify.get("results") != null) {
if (handler != null)
handler.onSemanticEvent(new Notification(notify));
} else if (notify.get("code") != null) {
if (handler != null)
handler.onError(new ErrorResponse(notify));
} else
logger.error("Unknown message: " + message);
}
use of it.unibo.arces.wot.sepa.commons.response.UnsubscribeResponse in project SEPA by arces-wot.
the class SPUManager method unsubscribe.
// public Response unsubscribe(String sid, String gid) {
// logger.log(Level.getLevel("SPUManager"), "@unsubscribe " + sid + " " + gid);
// return internalUnsubscribe(sid, gid, true);
// }
// public void killSubscription(String sid, String gid) {
// logger.log(Level.getLevel("SPUManager"), "@killSubscription " + sid + " " + gid);
// internalUnsubscribe(sid, gid, false);
// }
public Response unsubscribe(String sid, String gid) {
// private Response internalUnsubscribe(String sid, String gid, boolean dep) {
// + " " + dep);
logger.log(Level.getLevel("SPUManager"), "@internalUnsubscribe " + sid + " " + gid);
try {
// Subscriber sub = Subscriptions.getSubscriber(sid);
//
// endOfProcessing(sub.getSPU());
//
// synchronized (activeSpus) {
// activeSpus.remove(sub.getSPU());
// }
Subscriptions.removeSubscriber(sid);
} catch (SEPANotExistsException e) {
logger.warn("@internalUnsubscribe SID not found: " + sid);
return new ErrorResponse(500, "sid_not_found", "Unregistering a not existing subscriber: " + sid);
}
// if (dep)
Dependability.onUnsubscribe(gid, sid);
return new UnsubscribeResponse(sid);
}
Aggregations