Just a second...

Handling subscriptions to missing topics

A client can handle subscription requests for topics that do not exist and can act on those notifications, for example, by creating a topic on demand that matches the request.

Required permissions: modify_topic, register_handler

The client can register itself as a handler for missing topics for any branch of the topic tree. The client is notified of any subscription using a selector that does not resolve to any existing topics. This enables the client to create the missing topics if your application requires this.

Note: As of Diffusion™ Cloud 6.7, the notification contains the full set of session properties of the requesting session as well as the names of the servers that the request has passed through.

The missing topic handler is removed when the registering session is closed. If the registering session loses connection, it goes into DISCONNECTED state. When in DISCONNECTED state the handler remains active but cannot pass on the notifications to the client. If the client then closes, these notifications are discarded.

To ensure that missing topic notifications are always received by your solution, you can use multiple clients to register missing topic handlers. Ensure that if any of these clients lose connection they go straight to CLOSED state by setting the reconnection timeout to zero so that when the client loses connection it closes straight away, and further missing topic notifications are routed to a handler registered by another client.

Identifying when a particular client connects

You can use missing topic notifications when your application needs to detect when a particular uniquely identifiable client connects.

If a client session subscribes to a topic with a path that does not exist and is unique to that client (for example, the path contains a user ID), this will trigger a missing topic notification, informing any handler that the client has connected.

Registering a missing topic notification handler

Register a handler against a branch of the topic tree:

session.topics.addMissingTopicHandler("topic_branch", {
	// Implement handling code
-(void)registerAsMissingTopicHandlerForSession:(PTDiffusionSession *const)session {
    [session.topicControl addMissingTopicHandler:self
                               completionHandler:^(PTDiffusionTopicTreeRegistration *const registration, NSError *const error)
        if (registration) {
            NSLog(@"Registered as missing topic handler.");
        } else {
            NSLog(@"Failed to register as missing topic handler. Error: %@", error);
Java and Android
TopicControl topicControl = session.feature(TopicControl.class);
topicControl.addMissingTopicHandler("topic_branch", new MissingTopicNotificationHandler());
ITopicControl topicControl  = session.TopicControl;
var missingTopicHandler = new MissingTopicHandler();
topicControl.AddMissingTopicHandler( topic_branch, missingTopicHandler );
        .on_missing_topic = on_missing_topic,
        .topic_path = topic_branch,
        .context = NULL

missing_topic_register_handler(session, handler);