All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kolibrifx.plovercrest.server.internal.protocol.GlobalSubscriptionsHandler Maven / Gradle / Ivy

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();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy