/* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/
package org.geoserver.wps.remote.plugin;
import java.util.Map;
import java.util.logging.Logger;
import org.geoserver.wps.remote.RemoteProcessClientListener;
import org.geotools.util.logging.Logging;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Packet;
/**
* Listens for "PROGRESS" messages from XMPP service channels and takes action accordingly.
*
* @author Alessio Fabiani, GeoSolutions
*
*/
public class XMPPProgressMessage implements XMPPMessage {
/** The LOGGER */
public static final Logger LOGGER = Logging.getLogger(XMPPMessage.class.getPackage().getName());
@Override
public boolean canHandle(Map<String, String> signalArgs) {
if (signalArgs != null && signalArgs.get("topic") != null)
return signalArgs.get("topic").equals("progress");
return false;
}
@Override
public void handleSignal(XMPPClient xmppClient, Packet packet, Message message,
Map<String, String> signalArgs) {
final String pID = signalArgs.get("id");
final Double progress = Double.parseDouble(signalArgs.get("message"));
// NOTIFY LISTENERS
for (RemoteProcessClientListener listener : xmppClient.getRemoteClientListeners()) {
listener.progress(pID, progress);
}
}
}