public ClientConsumingRecordTopics(string serverUrl, IRatesListener listener) { _listener = listener; session = Diffusion.Sessions.Principal("client").Password("password").Open(serverUrl); // Create the record metadata for the rates topic. It has two decimal fields which are maintained to 5 // decimal places and allow empty values. var mf = Diffusion.Metadata; var recordMetadata = mf.RecordBuilder("Rates") .Add(mf.DecimalBuilder("Bid").SetScale(5).SetAllowsEmpty(true).Build()) .Add(mf.DecimalBuilder("Ask").SetScale(5).SetAllowsEmpty(true).Build()) .Build(); // Use the Topics feature to add a topic stream and subscribe to all topics under the root. var topics = session.GetTopicsFeature(); var topicSelector = string.Format("?{0}//", RootTopic); topics.AddTopicStream(topicSelector, new RatesTopicStream(recordMetadata)); topics.Subscribe(topicSelector, new TopicsCompletionCallbackDefault()); }
public ClientConsumingRecordTopics( string serverUrl, IRatesListener listener ) { _listener = listener; session = Diffusion.Sessions.Principal( "client" ).Password( "password" ).Open( serverUrl ); // Create the record metadata for the rates topic. It has two decimal fields which are maintained to 5 // decimal places and allow empty values. var mf = Diffusion.Metadata; var recordMetadata = mf.RecordBuilder( "Rates" ) .Add( mf.DecimalBuilder( "Bid" ).SetScale( 5 ).SetAllowsEmpty( true ).Build() ) .Add( mf.DecimalBuilder( "Ask" ).SetScale( 5 ).SetAllowsEmpty( true ).Build() ) .Build(); // Use the Topics feature to add a topic stream and subscribe to all topics under the root. var topics = session.GetTopicsFeature(); var topicSelector = string.Format( "?{0}//", RootTopic ); topics.AddTopicStream( topicSelector, new RatesTopicStream( recordMetadata ) ); topics.Subscribe( topicSelector, new TopicsCompletionCallbackDefault() ); }