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.
파일 보기 프로젝트 열기: pushtechnology/diffusion-examples

공개 메소드들

메소드 설명
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