use of com.google.common.eventbus.Subscribe in project syncany by syncany.
the class WebServer method onGetFileResponseInternal.
@Subscribe
public void onGetFileResponseInternal(GetFileFolderResponseInternal fileResponseInternal) {
File tempFile = fileResponseInternal.getTempFile();
GetFileFolderResponse fileResponse = fileResponseInternal.getFileResponse();
fileTokenTempFileCache.asMap().put(fileResponse.getTempToken(), tempFile);
eventBus.post(fileResponse);
}
use of com.google.common.eventbus.Subscribe in project syncany by syncany.
the class WebServer method onResponse.
@Subscribe
public void onResponse(Response response) {
try {
// Send to one or many receivers
boolean responseWithoutRequest = response.getRequestId() == null || response.getRequestId() <= 0;
if (responseWithoutRequest) {
sendBroadcast(response);
} else {
HttpServerExchange responseToHttpServerExchange = requestIdRestSocketCache.asMap().get(response.getRequestId());
WebSocketChannel responseToWebSocketChannel = requestIdWebSocketCache.asMap().get(response.getRequestId());
if (responseToHttpServerExchange != null) {
sendTo(responseToHttpServerExchange, response);
} else if (responseToWebSocketChannel != null) {
sendTo(responseToWebSocketChannel, response);
} else {
logger.log(Level.WARNING, "Cannot send message, because request ID in response is unknown or timed out." + response);
}
}
} catch (Exception e) {
logger.log(Level.SEVERE, "Cannot send response.", e);
}
}
use of com.google.common.eventbus.Subscribe in project syncany by syncany.
the class WatchRunner method onRequestReceived.
@Subscribe
public void onRequestReceived(FolderRequest folderRequest) {
File requestRootFolder = new File(folderRequest.getRoot());
boolean localDirMatches = requestRootFolder.equals(config.getLocalDir());
if (localDirMatches) {
logger.log(Level.INFO, "Received " + folderRequest);
try {
if (!watchOperation.isSyncRunning() && !watchOperation.isSyncRequested()) {
watchOperation.pause();
FolderRequestHandler handler = FolderRequestHandler.createFolderRequestHandler(folderRequest, config);
Response response = handler.handleRequest(folderRequest);
if (response != null) {
eventBus.post(response);
}
watchOperation.resume();
} else {
logger.log(Level.WARNING, "FolderRequest discarded : ", folderRequest);
eventBus.post(new AlreadySyncingResponse(folderRequest.getId(), "FolderRequest discarded."));
}
} catch (Exception e) {
logger.log(Level.FINE, "Failed to process request", e);
eventBus.post(new BadRequestResponse(folderRequest.getId(), "Invalid request."));
}
}
}
use of com.google.common.eventbus.Subscribe in project bazel by bazelbuild.
the class AggregatingTestListener method buildCompleteEvent.
@Subscribe
public void buildCompleteEvent(BuildCompleteEvent event) {
BuildResult result = event.getResult();
if (result.wasCatastrophe()) {
blazeHalted = true;
}
buildComplete(result.getActualTargets(), result.getSuccessfulTargets());
}
use of com.google.common.eventbus.Subscribe in project bazel by bazelbuild.
the class ExperimentalEventHandler method testSummary.
@Subscribe
public synchronized void testSummary(TestSummary summary) {
stateTracker.testSummary(summary);
if (testSummaryProvidesNewInformation(summary)) {
// For failed test, write the failure to the scroll-back buffer immediately
try {
clearProgressBar();
crlf();
setEventKindColor(EventKind.ERROR);
terminal.writeString("" + summary.getStatus() + ": ");
terminal.resetTerminal();
terminal.writeString(summary.getTarget().getLabel().toString());
terminal.writeString(" (Summary)");
crlf();
for (Path logPath : summary.getFailedLogs()) {
terminal.writeString(" " + logPath.getPathString());
crlf();
}
if (showProgress && cursorControl) {
addProgressBar();
}
terminal.flush();
} catch (IOException e) {
LOG.warning("IO Error writing to output stream: " + e);
}
} else {
refresh();
}
}
Aggregations