Search Results for

    Show / Hide Table of Contents

    Runtime services

    Whenever you need to work with the capabilities of the adapter, you do so by leveraging adapter services.

    For example, to start using the ChannelClient and ChannelProvider APIs, you first need to get the channels service:

    var channels = runtime.GetService<IChannels>();
    

    At this point, for example, you can then create a channel client that is ready to talk to any channels providers that maybe running within OpenFin.

    var channelClient = channels.CreateClient("CHANNEL_NAME");
    channelClient.Opened += (s, e) =>
    {
        Debug.WriteLine("The ChannelClient has been opened");
    };
    
    try
    {
        await channelClient.ConnectAsync();
    }
    catch
    {
        Debug.WriteLine("Channel connection failed");
    }
    

    This same pattern is used for the other major API groups within the adapter:

    • IChannels
    • IInterApplicationBus
    • IInterop

    The pattern is also used any extensions that you wish to use.

    One of the advantages of this method is the ability to mock these service requests during unit tests. Refer to Testing.

    In This Article
    Back to top Copyright OpenFin