/// <summary> /// Constructor. /// </summary> /// <param name="serverUrl">The server url, for example "ws://diffusion.example.com:80".</param> public ControlClientUpdatingRecordTopics(string serverUrl) { session = Diffusion.Sessions.Principal("client").Password("password").Open(serverUrl); topicControl = session.GetTopicControlFeature(); var mf = Diffusion.Metadata; // Create the record metadata for the rates topic. It has 2 decimal fields which are maintained to 5 // decimal places and allow empty values. recordMetadata = mf.RecordBuilder("Rates") .Add(mf.DecimalBuilder("Buy").SetScale(5).SetAllowsEmpty(true).Build()) .Add(mf.DecimalBuilder("Sell").SetScale(5).SetAllowsEmpty(true).Build()) .Build(); // Create the topic details to be used for all rates topics topicDetails = topicControl.CreateDetailsBuilder <IRecordTopicDetailsBuilder>() .EmptyFieldValue(Constants.EMPTY_FIELD_STRING) .Metadata(mf.Content("CurrencyDetails", recordMetadata)) .Build(); // Create a delta builder that can be reused for bid-only changes deltaRecordBuilder = Diffusion.Content.NewDeltaRecordBuilder(recordMetadata) .EmptyFieldValue(Constants.EMPTY_FIELD_STRING); var updateControl = session.GetTopicUpdateControlFeature(); updateFactory = updateControl.UpdateFactory <IContentUpdateFactory>(); // Register as an updater for all topics under the root updateControl.RegisterUpdateSource(RootTopic, new TopicUpdateSource(topicUpdater)); }
static RefreshIntervalTopicSource() { var metadataFactory = Diffusion.Metadata; var recordBuilder = metadataFactory.RecordBuilder("RefreshInterval"); recordBuilder.Add(metadataFactory.Integer(frequencyFieldName), 1, 1); recordBuilder.Add(metadataFactory.Integer(sleepDurationFieldName), 1, 1); recordMetadata = recordBuilder.Build(); }
static ButtonStatesTopicSource() { var metadataFactory = Diffusion.Metadata; var recordBuilder = metadataFactory.RecordBuilder("ButtonsState"); sortedButtonNames = Enum.GetNames(typeof(DataGenerators.CarButtons)); foreach (var buttonName in sortedButtonNames) { var integerString = metadataFactory.Integer(buttonName); recordBuilder.Add(integerString, 1, 1); } recordMetadata = recordBuilder.Build(); }
/// <summary> /// Constructor. /// </summary> /// <param name="metadata">The metadata.</param> public RatesTopicStream(IMRecord metadata) { this.metadata = metadata; }
/// <summary> /// Constructor. /// </summary> /// <param name="metadata">The metadata.</param> public RatesTopicStream( IMRecord metadata ) { this.metadata = metadata; }
/// <summary> /// Constructor. /// </summary> /// <param name="serverUrl">The server url, for example "ws://diffusion.example.com:80".</param> public ControlClientUpdatingRecordTopics( string serverUrl ) { session = Diffusion.Sessions.Principal( "client" ).Password( "password" ).Open( serverUrl ); topicControl = session.GetTopicControlFeature(); var mf = Diffusion.Metadata; // Create the record metadata for the rates topic. It has 2 decimal fields which are maintained to 5 // decimal places and allow empty values. recordMetadata = mf.RecordBuilder( "Rates" ) .Add( mf.DecimalBuilder( "Buy" ).SetScale( 5 ).SetAllowsEmpty( true ).Build() ) .Add( mf.DecimalBuilder( "Sell" ).SetScale( 5 ).SetAllowsEmpty( true ).Build() ) .Build(); // Create the topic details to be used for all rates topics topicDetails = topicControl.CreateDetailsBuilder<IRecordTopicDetailsBuilder>() .EmptyFieldValue( Constants.EMPTY_FIELD_STRING ) .Metadata( mf.Content( "CurrencyDetails", recordMetadata ) ) .Build(); // Create a delta builder that can be reused for bid-only changes deltaRecordBuilder = Diffusion.Content.NewDeltaRecordBuilder( recordMetadata ) .EmptyFieldValue( Constants.EMPTY_FIELD_STRING ); var updateControl = session.GetTopicUpdateControlFeature(); updateFactory = updateControl.UpdateFactory<IContentUpdateFactory>(); // Register as an updater for all topics under the root updateControl.RegisterUpdateSource( RootTopic, new TopicUpdateSource( topicUpdater ) ); }