Exemple #1
0
        /// <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));
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public ControlClientUpdatingPagedTopics()
        {
            session = Diffusion.Sessions.Principal("control").Password("password")
                      .Open("ws://diffusion.example.com:80");

            topicControl = session.GetTopicControlFeature();
            var updateControl = session.GetTopicUpdateControlFeature();

            orderedUpdateFactory   = updateControl.UpdateFactory <IPagedRecordOrderedUpdateFactory>();
            unorderedUpdateFactory = updateControl.UpdateFactory <IPagedStringUnorderedUpdateFactory>();

            var metadata = Diffusion.Metadata;

            // Create an unordered paged string topic
            topicControl.AddTopic(UnorderedTopic, topicControl.NewDetails(TopicType.PAGED_STRING),
                                  new TopicControlAddCallbackDefault());

            // Create an ordered paged record topic
            var recordMetadata = metadata.Record("Record", metadata.String("Name"), metadata.String("Address"));

            topicControl.AddTopic(OrderedTopic,
                                  topicControl.CreateDetailsBuilder <IPagedRecordTopicDetailsBuilder>()
                                  .Metadata(recordMetadata)
                                  .Order(new PagedRecordOrderKey("Name"))
                                  .Build(),
                                  new TopicControlAddCallbackDefault());

            // Register an updater for topics under the 'Paged' branch
            updateControl.RegisterUpdateSource("Paged", new UpdateSource());
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public ControlClientUpdatingPagedTopics()
        {
            session = Diffusion.Sessions.Principal( "control" ).Password( "password" )
                .Open( "ws://diffusion.example.com:80" );

            topicControl = session.GetTopicControlFeature();
            var updateControl = session.GetTopicUpdateControlFeature();

            orderedUpdateFactory = updateControl.UpdateFactory<IPagedRecordOrderedUpdateFactory>();
            unorderedUpdateFactory = updateControl.UpdateFactory<IPagedStringUnorderedUpdateFactory>();

            var metadata = Diffusion.Metadata;

            // Create an unordered paged string topic
            topicControl.AddTopic( UnorderedTopic, topicControl.NewDetails( TopicType.PAGED_STRING ),
                new TopicControlAddCallbackDefault() );

            // Create an ordered paged record topic
            var recordMetadata = metadata.Record( "Record", metadata.String( "Name" ), metadata.String( "Address" ) );

            topicControl.AddTopic( OrderedTopic,
                topicControl.CreateDetailsBuilder<IPagedRecordTopicDetailsBuilder>()
                    .Metadata( recordMetadata )
                    .Order( new PagedRecordOrderKey( "Name" ) )
                    .Build(),
                new TopicControlAddCallbackDefault() );

            // Register an updater for topics under the 'Paged' branch
            updateControl.RegisterUpdateSource( "Paged", new UpdateSource() );
        }
        /// <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 ) );
        }
        public ControlClientAddingTopics()
        {
            session = Diffusion.Sessions.Principal("control").Password("password")
                      .Open("ws://diffusion.example.com:80");

            topicControl = session.GetTopicControlFeature();
        }
        public ControlClientMissingTopicNotification() {
            clientSession = Diffusion.Sessions.Principal( "client" ).Password( "password" )
                .Open( "ws://diffusion.example.com:80" );

            topicControl = Diffusion.Sessions.Principal( "control" ).Password( "password" )
                .Open( "ws://diffusion.example.com:80" ).GetTopicControlFeature();

            Subscribe( "some/path10" );
        }
Exemple #7
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="serverUrl">for example "ws://diffusion.example.com:80"</param>
        public ControlClientUpdatingJSONTopics(string serverUrl)
        {
            session = Diffusion.Sessions.Principal("control").Password("password").Open(serverUrl);

            topicControl = session.GetTopicControlFeature();

            // Register as an updater for all topics under the root
            session.GetTopicUpdateControlFeature().RegisterUpdateSource(rootTopic,
                                                                        new MyTopicUpdateSource(valueUpdater));
        }
Exemple #8
0
        public ControlClientMissingTopicNotification()
        {
            clientSession = Diffusion.Sessions.Principal("client").Password("password")
                            .Open("ws://diffusion.example.com:80");

            topicControl = Diffusion.Sessions.Principal("control").Password("password")
                           .Open("ws://diffusion.example.com:80").GetTopicControlFeature();

            Subscribe("some/path10");
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="callback">The callback for updates.</param>
        public ControlClientAsUpdateSource( ITopicUpdaterUpdateCallback callback )
        {
            updateCallback = callback;

            session = Diffusion.Sessions.Principal( "control" ).Password( "password" )
                .Open( "ws://diffusion.example.com;80" );

            topicControl = session.GetTopicControlFeature();
            updateControl = session.GetTopicUpdateControlFeature();
        }
Exemple #10
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="callback">The callback for updates.</param>
        public ControlClientAsUpdateSource(ITopicUpdaterUpdateCallback callback)
        {
            updateCallback = callback;

            session = Diffusion.Sessions.Principal("control").Password("password")
                      .Open("ws://diffusion.example.com;80");

            topicControl  = session.GetTopicControlFeature();
            updateControl = session.GetTopicUpdateControlFeature();
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="serverUrl">for example "ws://diffusion.example.com:80"</param>
        public ControlClientUpdatingJSONTopics( string serverUrl )
        {
            session = Diffusion.Sessions.Principal( "control" ).Password( "password" ).Open( serverUrl );

            topicControl = session.GetTopicControlFeature();

            // Register as an updater for all topics under the root
            session.GetTopicUpdateControlFeature().RegisterUpdateSource( rootTopic,
                new MyTopicUpdateSource( valueUpdater ) );
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public ControlClientUpdatingTopic()
        {
            session = Diffusion.Sessions.Principal("control").Password("password")
                      .Open("ws://diffusion.example.com:80");

            topicControl  = session.GetTopicControlFeature();
            updateControl = session.GetTopicUpdateControlFeature();

            // Create a single-value topic.
            topicControl.AddTopicFromValue(Topic, TopicType.SINGLE_VALUE, new TopicControlAddCallbackDefault());
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public ControlClientUpdatingTopic()
        {
            session = Diffusion.Sessions.Principal( "control" ).Password( "password" )
                .Open( "ws://diffusion.example.com:80" );

            topicControl = session.GetTopicControlFeature();
            updateControl = session.GetTopicUpdateControlFeature();

            // Create a single-value topic.
            topicControl.AddTopicFromValue( Topic, TopicType.SINGLE_VALUE, new TopicControlAddCallbackDefault() );
        }
        public TopicManager(ISession session, DataGenerators.ICarControlsDataGenerator carControlsDataGenerator, DataGenerators.ICarStateDataGenerator carStateDataGenerator, RefreshIntervalManager refreshIntervalManager, Metrics metrics)
        {
            this.carControlsDataGenerator = carControlsDataGenerator;
            this.carStateDataGenerator = carStateDataGenerator;
            this.refreshIntervalManager = refreshIntervalManager;
            this.metrics = metrics;

            topics = session.GetTopicsFeature();
            topicControl = session.GetTopicControlFeature();
            topicUpdateControl = session.GetTopicUpdateControlFeature();

            topicPathsPendingAddition = new List<string>();

            // The first thing we need to do is kick of an asynchronous request to see
            // whether our root topic path already exists.
            var topicDetailsHandler = new Handlers.TopicDetailsHandler();
            topicDetailsHandler.Success += topicDetailsHandler_Success;
            topics.GetTopicDetails(rootTopicPath, TopicDetailsLevel.BASIC, topicDetailsHandler);
        }
        public TopicManager(ISession session, DataGenerators.ICarControlsDataGenerator carControlsDataGenerator, DataGenerators.ICarStateDataGenerator carStateDataGenerator, RefreshIntervalManager refreshIntervalManager, Metrics metrics)
        {
            this.carControlsDataGenerator = carControlsDataGenerator;
            this.carStateDataGenerator    = carStateDataGenerator;
            this.refreshIntervalManager   = refreshIntervalManager;
            this.metrics = metrics;

            topics             = session.GetTopicsFeature();
            topicControl       = session.GetTopicControlFeature();
            topicUpdateControl = session.GetTopicUpdateControlFeature();

            topicPathsPendingAddition = new List <string>();

            // The first thing we need to do is kick of an asynchronous request to see
            // whether our root topic path already exists.
            var topicDetailsHandler = new Handlers.TopicDetailsHandler();

            topicDetailsHandler.Success += topicDetailsHandler_Success;
            topics.GetTopicDetails(rootTopicPath, TopicDetailsLevel.BASIC, topicDetailsHandler);
        }
 public MissingTopicHandler(ITopicControl topicControl, AddTopicAndProceed proceedCallback)
 {
     theTopicControl    = topicControl;
     theProceedCallback = proceedCallback;
 }