use of org.onosproject.ui.UiMessageHandler in project onos by opennetworkinglab.
the class UiWebSocket method onWebSocketText.
@Override
public void onWebSocketText(String data) {
lastActive = System.currentTimeMillis();
try {
ObjectNode message = (ObjectNode) mapper.reader().readTree(data);
String type = message.path(EVENT).asText(UNKNOWN);
if (sessionToken == null) {
authenticate(type, message);
} else {
UiMessageHandler handler = handlers.get(type);
if (handler != null) {
log.debug("RX message: {}", message);
handler.process(message);
} else {
log.warn("No GUI message handler for type {}", type);
}
}
} catch (Error | Exception e) {
log.warn("Unable to parse GUI message {} due to", data, e);
log.debug("Boom!!!", e);
}
}
use of org.onosproject.ui.UiMessageHandler in project onos by opennetworkinglab.
the class UiWebSocket method createHandlersAndOverlays.
// Creates new message handlers.
private synchronized void createHandlersAndOverlays() {
log.debug("Creating handlers and overlays...");
handlers = new HashMap<>();
overlayCache = new TopoOverlayCache();
overlay2Cache = new Topo2OverlayCache();
Map<Class<?>, UiMessageHandler> handlerInstances = new HashMap<>();
UiExtensionService service = directory.get(UiExtensionService.class);
lionBundleMap = generateLionMap(service);
service.getExtensions().forEach(ext -> {
UiMessageHandlerFactory factory = ext.messageHandlerFactory();
if (factory != null) {
factory.newHandlers().forEach(handler -> {
try {
handler.init(this, directory);
injectLionBundles(handler, lionBundleMap);
handler.messageTypes().forEach(type -> handlers.put(type, handler));
handlerInstances.put(handler.getClass(), handler);
} catch (Exception e) {
log.warn("Unable to setup handler {} due to", handler, e);
}
});
}
registerOverlays(ext);
});
handlerCrossConnects(handlerInstances);
overlay2Cache.switchOverlay(null, Traffic2Overlay.OVERLAY_ID);
log.debug("#handlers = {}, #overlays = Topo: {}, Topo2: {}", handlers.size(), overlayCache.size(), overlay2Cache.size());
}
Aggregations