C# 클래스 Examples.ClientConsumingRecordTopics

This demonstrates a client consuming record topics and reading the content using a structured reader. This makes use of the 'Topics' feature only. To subscribe to a topic, the client session must have the 'read_topic' permission for that branch of the topic tree. This example receives updates to currency conversion rates via a branch of the topic tree where the root topic is called 'FX'; beneath which is a topic for each base currency, and beneath each of those is a topic for each target currency which contains the bid and ask rates. So a topic 'FX/GBP/USD' would contain the rates for GBP to USD. This example maintains a local dictionary of the rates and also notifies a listener of any rates changes. The example shows the use of empty fields. Any of the rates can be empty (meaning the rate is not available in this example), so it can be an empty string in the topic value. Because delta updates use a zero-length string to indicate that a field has not changed, a special 'empty field' value is used to indicate that the field has changed to empty in deltas. The client application must therefore convert empty string values to "" for the local rate value.
파일 보기 프로젝트 열기: pushtechnology/diffusion-examples

공개 메소드들

메소드 설명
ApplyUpdate ( TopicUpdateType type, string currency, string targetCurrency, string bid, string ask ) : void

This is used to apply topic stream updates to the local dictionary.

ClientConsumingRecordTopics ( string serverUrl, IRatesListener listener ) : System.Collections.Generic
Close ( ) : void

Close session.

GetRates ( string currency, string targetCurrency ) : Rates

Returns the rates for a given base and target currency.

RemoveCurrency ( string currency ) : void

This is used by the topic stream when notified of the unsubscription from a base currency topic. It will remove the base currency and all of its rates from the local dictionary.

RemoveRate ( string currency, string targetCurrency ) : void

This is used by the topic stream when notification of the unsubscription from a target currency topic. It will remove the rates for the target currency under the base currency.

메소드 상세

ApplyUpdate() 공개 정적인 메소드

This is used to apply topic stream updates to the local dictionary.
public static ApplyUpdate ( TopicUpdateType type, string currency, string targetCurrency, string bid, string ask ) : void
type TopicUpdateType The update may be a snapshot or a delta.
currency string The base currency.
targetCurrency string The target currency.
bid string The bid rate.
ask string The ask rate.
리턴 void

ClientConsumingRecordTopics() 공개 메소드

public ClientConsumingRecordTopics ( string serverUrl, IRatesListener listener ) : System.Collections.Generic
serverUrl string
listener IRatesListener
리턴 System.Collections.Generic

Close() 공개 메소드

Close session.
public Close ( ) : void
리턴 void

GetRates() 공개 메소드

Returns the rates for a given base and target currency.
public GetRates ( string currency, string targetCurrency ) : Rates
currency string The base currency.
targetCurrency string The target currency.
리턴 Rates

RemoveCurrency() 공개 정적인 메소드

This is used by the topic stream when notified of the unsubscription from a base currency topic. It will remove the base currency and all of its rates from the local dictionary.
public static RemoveCurrency ( string currency ) : void
currency string The currency to remove.
리턴 void

RemoveRate() 공개 정적인 메소드

This is used by the topic stream when notification of the unsubscription from a target currency topic. It will remove the rates for the target currency under the base currency.
public static RemoveRate ( string currency, string targetCurrency ) : void
currency string The base currency.
targetCurrency string The target currency.
리턴 void