C# Класс Examples.ControlClientUpdatingJSONTopics

This example shows a control client creating a JSON topic and sending updates to it. There will be a topic for each currency for which rates are provided. The topic will be created under the FX topic - so, for example FX/GBP will contain a map of all rate conversions from the base GBP currency. The rates are represented as string decimal values (e.g. "12.457"). The addRates method shows how to create a new rates topic, specifying its initial map of values. The changeRates method which takes a map shows how to completely replace the set of rates for a currency with a new map of rates. The changeRates method which takes a string shows an alternative mechanism where the new rates are simply supplied as a JSON string. Either of the changeRates methods could be used and after the first usage for any topic the values is cached, and so subsequent set calls can compare with the last value and send only the differences to the server.
Показать файл Открыть проект

Открытые методы

Метод Описание
AddRates ( string currency, string>.IDictionary values, ITopicControlAddContextCallback callback ) : void

Add a new rates topic.

ChangeRates ( string currency, string>.IDictionary values, ITopicUpdaterUpdateContextCallback callback ) : void

Update and existing rates topic, replacing the rates mappings with a new set of mappings.

ChangeRates ( string currency, string jsonString, ITopicUpdaterUpdateContextCallback callback ) : void

Update an existing rates topic, replacing the rates mappings with a new set of mappings specified as a JSON string, for example {"USD":"123.45","HKD":"456.3"}.

ControlClientUpdatingJSONTopics ( string serverUrl ) : System

Constructor.

close ( ) : void

Close the session.

removeRates ( string currency, ITopicControlRemoveContextCallback callback ) : void

Remove a rates entry (remove its topic) and clear cached value for the topic.

Приватные методы

Метод Описание
MapToJSON ( string>.IDictionary values ) : IJSON

Convert a given map to a JSON object.

RateTopicName ( string currency ) : string

Generate a hierarchical topic name for a rates topic. e.g. for currency=GBP would return "FX/GBP".

Описание методов

AddRates() публичный Метод

Add a new rates topic.
public AddRates ( string currency, string>.IDictionary values, ITopicControlAddContextCallback callback ) : void
currency string the base currency
values string>.IDictionary the full map of initial rates values
callback ITopicControlAddContextCallback reports outcome
Результат void

ChangeRates() публичный Метод

Update and existing rates topic, replacing the rates mappings with a new set of mappings.
public ChangeRates ( string currency, string>.IDictionary values, ITopicUpdaterUpdateContextCallback callback ) : void
currency string the base currency
values string>.IDictionary the mew rates values
callback ITopicUpdaterUpdateContextCallback reports outcome
Результат void

ChangeRates() публичный Метод

Update an existing rates topic, replacing the rates mappings with a new set of mappings specified as a JSON string, for example {"USD":"123.45","HKD":"456.3"}.
public ChangeRates ( string currency, string jsonString, ITopicUpdaterUpdateContextCallback callback ) : void
currency string the base currency
jsonString string a JSON string specifying the map of currency rates
callback ITopicUpdaterUpdateContextCallback reports outcome
Результат void

ControlClientUpdatingJSONTopics() публичный Метод

Constructor.
public ControlClientUpdatingJSONTopics ( string serverUrl ) : System
serverUrl string for example "ws://diffusion.example.com:80"
Результат System

close() публичный Метод

Close the session.
public close ( ) : void
Результат void

removeRates() публичный Метод

Remove a rates entry (remove its topic) and clear cached value for the topic.
public removeRates ( string currency, ITopicControlRemoveContextCallback callback ) : void
currency string the currency to be removed
callback ITopicControlRemoveContextCallback reports the outcome
Результат void