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

com.openfin.desktop.channel.AbstractServiceClient Maven / Gradle / Ivy

There is a newer version: 11.0.2
Show newest version
package com.openfin.desktop.channel;

import com.openfin.desktop.Ack;
import com.openfin.desktop.AckListener;
import com.openfin.desktop.AsyncCallback;
import com.openfin.desktop.DesktopConnection;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class AbstractServiceClient {
    protected Logger logger = LoggerFactory.getLogger(this.getClass().getName());

    protected String channelName;  // default channel name
    protected ChannelClient channelClient;
    protected DesktopConnection desktopConnection;

    protected AbstractServiceClient(String channelName, DesktopConnection desktopConnection) {
        this.channelName = channelName;
        this.desktopConnection = desktopConnection;
    }

    protected void setChannelName(String name) {
        this.channelName = name;
        logger.debug(String.format("Setting FDC3 provider channel name %s", name));
    }

    public void connect(AckListener ackListener) {
        desktopConnection.getChannel(this.channelName).connect(
                new AsyncCallback() {
                    @Override
                    public void onSuccess(ChannelClient client) {
                        AbstractServiceClient.this.channelClient = client;
                        AbstractServiceClient.this.onChannelConnected();
                        Ack ack = new Ack(null, AbstractServiceClient.this);
                        logger.debug(String.format("Connected to service %s", AbstractServiceClient.this.channelName));
                        ackListener.onSuccess(ack);
                    }
                });
    }

    protected void onChannelConnected() {
        logger.debug(String.format("Connected to channel %s", this.channelName));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy