Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## Version 0.1.5

- Added Broadcasting API lib v0.57.
- Fixed BMP-8259 - NullPointerException in HandlerManager.

## Version 0.1.1

- make ctrl+f search
Expand Down
2 changes: 1 addition & 1 deletion developer-addon/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ configurations {
implementation.canBeResolved = true
}

def version = "0.1.4"
def version = "0.1.5"
def baseName = "${LOWEST_BOOKMAP_VERSION}---${HIGHEST_BOOKMAP_VERSION}---2---python-api---${version}"

dependencies {
Expand Down
4 changes: 3 additions & 1 deletion serverside-rpc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ sourceCompatibility = JavaVersion.VERSION_14
targetCompatibility = JavaVersion.VERSION_14

group 'com.bookmap.api.rpc'
version '0.1.2'
version '0.1.5'

repositories {
mavenCentral()
Expand All @@ -36,6 +36,8 @@ dependencies {
implementation group: 'com.bookmap.api', name: 'api-core', version: lowerBookmapVersion
implementation group: 'com.bookmap.api', name: 'api-simplified', version: lowerBookmapVersion

implementation files("libs/broadcasting-api-0.57.jar")

compileOnly group: 'com.google.code.gson', name: 'gson', version: '2.8.9'

fatJarLib group: 'com.google.dagger', name: 'dagger', version: '2.42'
Expand Down
Binary file added serverside-rpc/libs/broadcasting-api-0.57.jar
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@

public class EventLoop implements Closeable {

private HandlerManager handlerManager;
private volatile HandlerManager handlerManager;
private final BlockingQueue<AbstractEvent> events = new LinkedBlockingQueue<>();
private final AtomicBoolean isRun = new AtomicBoolean(true);
private final ExecutorService eventQueueReader = Executors.newSingleThreadExecutor();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could lead to the problem in case we enable/disable the addon. E.g. if you start the add-on and then remove the checkbox and then check it again - this executor service won't be initialized


public EventLoop() {
ExecutorService eventQueueReader = Executors.newSingleThreadExecutor();
eventQueueReader.execute(() -> {
try {
while (isRun.get()) {
if(this.handlerManager == null) {
continue;
}
Comment on lines +23 to +25
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting issue

AbstractEvent event = events.poll(10, TimeUnit.SECONDS);
if (event == null) {
continue;
Expand All @@ -41,6 +44,7 @@ public void pushEvent(AbstractEvent event) {
@Override
public void close() throws IOException {
isRun.set(false);
eventQueueReader.shutdown();
}

public void setHandlerManager(HandlerManager handlerManager) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public void subscribeToLiveData(String generatorName, EventLoop eventLoop, Strin

broadcasterConsumer.setListenersForGenerator(providerName, generatorName, filterListener, new SettingsListener(eventLoop, generatorName));
broadcasterConsumer.subscribeToLiveData(providerName, generatorInfo.getGeneratorName(),
Event.class, eventListener, subscriptionListener);
eventListener, subscriptionListener);
});
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@ public RpcProviderStatusListener(ProviderStatusService providerStatusService) {
}

@Override
public void providerBecameAvailable(String providerName) {
public void providerBecameAvailable(String providerName, String providerId) {
providerStatusService.addProvider(providerName);
}

@Override
public void providerBecameUnavailable(String providerName) {
public void providerBecameUnavailable(String providerName, String providerId) {
providerStatusService.removeProvider(providerName);
}

@Override
public void providerUpdateGenerators(String providerName, List<GeneratorInfo> generators) {
providerStatusService.updateProvider(providerName, generators);
public void providerUpdateGenerator(String providerName, String providerId, GeneratorInfo generator, boolean isOnline) {
providerStatusService.updateProvider(providerName, generator, isOnline);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ public void removeProvider(String providerName) {
eventLoop.pushEvent(new ProviderStatusEvent(providerToGenerators));
}

public void updateProvider(String providerName, List<GeneratorInfo> generators) {
providerToGenerators.put(providerName, generators.stream().map(JsonUtil::convertObjectToJsonString).toList());
public void updateProvider(String providerName, GeneratorInfo generator, boolean isOnline) {
List<String> generators = providerToGenerators.get(providerName);
if(isOnline){
generators.add(generator.getGeneratorName());
Comment on lines +39 to +40
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting issue

} else {
generators.remove(generator.getGeneratorName());
}

eventLoop.pushEvent(new ProviderStatusEvent(providerToGenerators));
}

Expand Down