Esempio n. 1
0
            public async void OnMissingTopic(IMissingTopicNotification notification)
            {
                //check our user has credentials to create a new topic


                //open up a control session
                var session      = Diffusion.Sessions.Principal("admin").Password("password").Open("ws://localhost:8080");
                var topicControl = session.TopicControl;

                List <String> strL = new List <String>
                {
                    SessionProperty.PRINCIPAL
                };

                session.ClientControl.GetSessionProperties(notification.SessionId, strL, new PropCallback());

                if (vals != null && vals.Count > 0)
                {
                    switch (vals[SessionProperty.PRINCIPAL])
                    {
                    case "admin":
                        await topicControl.AddTopicAsync(notification.TopicPath, TopicType.JSON);

                        notification.Proceed();
                        break;

                    default:
                        notification.Cancel();
                        break;
                    }
                }
                session.Close();
            }
            /// <summary>
            /// Called when a client session requests a topic that does not exist, and the topic path belongs to part of
            /// the topic tree for which this handler was registered.
            ///
            /// The handler implementation should take the appropriate action (for example, create the topic), and then
            /// call IMissingTopicNotification.Proceed on the supplied notification. This allows the client request to
            /// continue and successfully resolve against the topic if it was created.
            ///
            /// A handler should always call Proceed() otherwise resources will continue to be reserved on the server
            /// and the client's request will not complete.
            /// </summary>
            /// <param name="notification"></param>
            public override void OnMissingTopic(IMissingTopicNotification notification)
            {
                var topicPath = notification.TopicPath;

                //TODO: TopicType.DELEGATED is deprecated.
                theTopicControl.AddTopic(topicPath,
                                         topicPath.StartsWith("topicroot/SV") ? TopicType.SINGLE_VALUE : TopicType.DELEGATED,
                                         notification, theProceedCallback);
            }
Esempio n. 3
0
 /// <summary>
 /// Called when a client session requests a topic that does not exist, and the topic path belongs to part of
 /// the topic tree for which this handler was registered.
 ///
 /// The handler implementation should take the appropriate action (for example, create the topic), and then call
 /// IMissingTopicNotification.Proceed on the supplied notification.  This allows the client request to continue
 /// and successfully resolve against the topic if it was created.
 ///
 /// A handler should always call Proceed() otherwise resources will continue to be reserved on the server and the
 /// client's request will not complete.
 /// </summary>
 /// <param name="notification">The client notification object.</param>
 void IMissingTopicHandler.OnMissingTopic(IMissingTopicNotification notification)
 {
     onMissingTopic.SetResult(notification);
 }
 /// <summary>
 /// Called when a client session requests a topic that does not exist, and the topic path belongs to part of
 /// the topic tree for which this handler was registered.
 ///
 /// The handler implementation should take the appropriate action (for example, create the topic), and then
 /// call IMissingTopicNotification.Proceed on the supplied notification. This allows the client request to
 /// continue and successfully resolve against the topic if it was created.
 ///
 /// A handler should always call Proceed() otherwise resources will continue to be reserved on the server
 /// and the client's request will not complete.
 /// </summary>
 /// <param name="notification">The client notification object.</param>
 void IMissingTopicHandler.OnMissingTopic( IMissingTopicNotification notification ) {
     onMissingTopic.SetResult( notification );
 }