Data Sharing

Enabling Channels

To add the Channel Selector to your window, you need to enable the channel window option:

io.windows().register(handle, options -> options.channel())

All Channels

To get a collection of all available Channel names, use the all() method:

CompletionStage<Collection<String>> allChannelNames = io.channels.all();

Creating Channel Context

A context data object can contain different types of data, e.g. RIC symbol, ClientID, AccountID:

Map<String, Object> data = new LinkedHashMap<>();
data.put("RIC", "BMW.GR");
data.put("ClientID", 235399);
data.put("AccountID", "X2343");

You can create a Channel context object:

ChannelContext<Map<String, Object>> channelContext = io.channels().create(window);

Subscribing for Data

When you want your app to track the current Channel data, you can use the subscribe() method of the Channel context object:

channelContext.subscribe((ChannelContextDataSubscriber<Map<String, Object>>) (channel, data) -> {
    // Each time the Channel context data is updated, this method will be invoked.
});

Publishing Data

To update the current Channel context data, use the publish() method:

channelContext.publish(Collections.singletonMap("RIC", "VOD.L"));