com.kolibrifx.plovercrest.server.internal.protocol.GlobalSubscriptionsHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plovercrest-server Show documentation
Show all versions of plovercrest-server Show documentation
Plovercrest server library.
The newest version!
/*
* Copyright (c) 2010-2017, KolibriFX AS. Licensed under the Apache License, version 2.0.
*/
package com.kolibrifx.plovercrest.server.internal.protocol;
import java.util.Set;
import com.kolibrifx.common.Disposable;
import com.kolibrifx.plovercrest.server.streams.StreamEngine;
import com.kolibrifx.plovercrest.server.streams.StreamNamesListener;
class GlobalSubscriptionsHandler implements Disposable {
private final Disposable disposable;
GlobalSubscriptionsHandler(final StreamConnection streamConnection, final StreamEngine streamEngine) {
disposable = streamEngine.addStreamNamesListener(new StreamNamesListener() {
@Override
public void onRemoved(final Set names) {
for (final String name : names) {
streamConnection.postGlobalTableDeleted(name);
}
}
@Override
public void onInit(final Set allNames) {
streamConnection.postGlobalResetTableNames(allNames);
}
@Override
public void onAdded(final Set names) {
for (final String name : names) {
streamConnection.postGlobalTableCreated(name);
}
}
});
}
@Override
public void close() {
disposable.close();
}
}