Diffusion .NET API
5.9.24
|
Represents a feature that provides a client session with the ability to manage topics. More...
Public Member Functions | |
ITopicSpecification | NewSpecification (TopicType topicType) |
Creates a new ITopicSpecification for a given topic type. More... | |
TBuilder | CreateDetailsBuilder< TBuilder > () |
Creates a new topic details builder to create ITopicDetails of a type corresponding to a given builder type. More... | |
ITopicDetails | NewDetails (TopicType topicType) |
Returns new topic details of the given type set with all default settings. More... | |
void | AddTopic< TContext > (string topicPath, ITopicDetails details, TContext context, ITopicControlAddContextCallback< TContext > callback) |
Sends a request to the server to add a topic. More... | |
void | AddTopic< TContext > (string topicPath, ITopicDetails details, IBytes value, TContext context, ITopicControlAddContextCallback< TContext > callback) |
Sends a request to the server to add a topic. More... | |
void | AddTopic (string topicPath, ITopicDetails details, ITopicControlAddCallback callback) |
Sends a request to the server to add a topic. More... | |
void | AddTopic (string topicPath, ITopicDetails details, IBytes value, ITopicControlAddCallback callback) |
Sends a request to the server to add a topic. More... | |
ITopicDetails | AddTopic (string topicPath, TopicType topicType, ITopicControlAddCallback callback) |
Sends a request to the server to add a topic. More... | |
ITopicDetails | AddTopic (string topicPath, TopicType topicType, IBytes value, ITopicControlAddCallback callback) |
Sends a request to the server to add a topic. More... | |
ITopicDetails | AddTopic< TContext > (string topicPath, TopicType topicType, TContext context, ITopicControlAddContextCallback< TContext > callback) |
Sends a request to the server to add a topic. More... | |
ITopicDetails | AddTopic< TContext > (string topicPath, TopicType topicType, IBytes value, TContext context, ITopicControlAddContextCallback< TContext > callback) |
Sends a request to the server to add a topic. More... | |
void | AddTopic< TContext > (string topicPath, ITopicSpecification specification, TContext context, ITopicControlAddContextCallback< TContext > callback) |
Sends a request to the server to add a topic. More... | |
void | AddTopic< TContext > (string topicPath, ITopicSpecification specification, IBytes value, TContext context, ITopicControlAddContextCallback< TContext > callback) |
Sends a request to the server to add a topic. More... | |
void | AddTopic (string topicPath, ITopicSpecification specification, ITopicControlAddCallback callback) |
Sends a request to the server to add a topic. More... | |
void | AddTopic (string topicPath, ITopicSpecification specification, IBytes value, ITopicControlAddCallback callback) |
Sends a request to the server to add a topic, specifying its initial value. More... | |
ITopicDetails | AddTopicFromValue< TValue > (string topicPath, TValue value, ITopicControlAddCallback callback) |
Sends a request to the server to add a topic where the type and initial value for the topic are derived from a provided value object. More... | |
ITopicDetails | AddTopicFromValue< TValue, TContext > (string topicPath, TValue value, TContext context, ITopicControlAddContextCallback< TContext > callback) |
Sends a request to the server to add a topic where the type and initial value for the topic are derived from a provided value object. More... | |
void | RemoveTopics (string topics, ITopicControlRemoveCallback callback) |
Sends a request to remove one or more topics at the server. More... | |
void | RemoveTopics< TContext > (string topics, TContext context, ITopicControlRemoveContextCallback< TContext > callback) |
Sends a request to remove one or more topics at the server. More... | |
void | Remove (string topicSelector, ITopicControlRemovalCallback callback) |
Sends a request to remove one or more topics at the server. More... | |
void | Remove< TContext > (string topicSelector, TContext context, ITopicControlRemovalContextCallback< TContext > callback) |
Sends a request to remove one or more topics at the server. More... | |
void | AddMissingTopicHandler (string topicPath, IMissingTopicHandler handler) |
Registers a IMissingTopicHandler to handle requests for a branch of the topic tree. More... | |
void | AddTopicEventListener (string topicPath, ITopicControlTopicEventListener listener) |
Register a ITopicControlTopicEventListener to receive topic events for a branch of the topic tree. More... | |
void | RemoveTopicsWithSession (string topicPath, Callbacks.ITopicTreeHandler registrationHandler) |
Registers a deferred action to remove a branch of the topic tree. More... | |
Additional Inherited Members | |
Properties inherited from PushTechnology.ClientInterface.Client.Features.IFeature | |
ISession | Session [get] |
Get the session that the service is associated with. More... | |
Represents a feature that provides a client session with the ability to manage topics.
This feature provides the following capabilities:
Creating a topic from a value
The simplest way to add a topic is using the AddTopicFromValue{TValue}(string,TValue,ITopicControlAddCallback) method. The topic type, metadata (if applicable) and initial value are derived from a supplied value as described below:
Value Type | Topic Type | Metadata | Initial Value |
IJSON | TopicType.JSON | Not applicable | The supplied value. |
IBinary | TopicType.BINARY | Not applicable | The supplied value. |
IContent built using IRecordContentBuilder | TopicType.RECORD | IMContent derived from records and values in the content. Numeric values will assume type IMIntegerString. Numeric values containing a '.' will assume type IMDecimalString with a scale equal to the number of digits after the decimal point and all other values will assume IMString. This means that if you intend a field to be a string you cannot give it an initial value that can be parsed as a number. It is not possible to derive repeating records or fields from content, each record or field in the content will get a separate metadata definition. If you want to use repeating records or fields, build the details manually. | The supplied content. |
IContent not built using IRecordContentBuilder | TopicType.SINGLE_VALUE | IMString | The supplied content as a string. |
Integer, Long, Short, Byte | TopicType.SINGLE_VALUE | IMIntegerString | derived from the string representation of the value supplied. |
Double, Float | TopicType.SINGLE_VALUE | IMDecimalString | Use of floating point numbers is not recommended but if supplied, the number is converted to a decimal value with half up rounding. |
Other | TopicType.SINGLE_VALUE | IMString | For all types other than those above the initial content is obtained from the object.ToString() method of the supplied object. |
For example, a topic could be added as follows:
The above call would create a single value topic with an integer value initialized to "42".
Alternatively a single value string topic initialized to a zero length string could be added as follows:
The actual ITopicDetails used to create the topic will be returned. These are generated by the call if required, or if there are already suitable details from a previous call, they will have been used.
Creating a simple topic type
Another easy way to add a topic is to use AddTopic(string,TopicType,ITopicControlAddCallback) specifying the type of topic to create. This will create a topic of the specified type with default properties. For example:
In some cases there may be a need to specify some additional properties. This may be done using AddTopic(string,ITopicSpecification,ITopicControlAddCallback) where the specification is created using NewSpecification(TopicType). For example:
Variants of these methods allow an initial value to be supplied for the topic. If a topic is not given an initial value, some topic types will assume a default initial value, whereas others may simply not have an initial value.
This method does not work for all topic types as some have complex requirements which need to be specified using ITopicDetails.
Complex topic creation
Some topics cannot be created using the simple mechanism specified above. For example, TopicType.RECORD topics would need to specify metadata. For such topics it is necessary to supply topic details which fully describe the type of topic and any other properties required for its creation. These details may be created using a ITopicDetailsBuilder of the correct type. In order to create a builder of the correct type it is necessary to supply the builder type to the CreateDetailsBuilder{TBuilder} method. For example:
After setting properties as required on the builder, it can be used to build immutable ITopicDetails which can then be used to add topics. For example:
If many topics are to be created with the same definition, it is recommended to use the same details instance as the feature is optimized to only transmit the details to the server once in this situation.
Creating topic tree hierarchies
When adding topics, intermediate nodes that do not already exist are automatically created as TopicType.STATELESS topics. So, in the following example, if A and B did not exist, they would automatically be created as stateless, with only "foo" being JSON:
Access control
To add and remove topic the client session needs TopicPermission.MODIFY_TOPIC permission to the branch of the topic tree being updated. If a session removes a topic (requiring TopicPermission.MODIFY_TOPIC permission for the topic path), descendant topics will also be removed regardless of the permissions at lower levels of the topic tree.
To register a missing topic handler the client needs GlobalPermission.REGISTER_HANDLER permissions.
Accessing the feature
This feature may be obtained from a session as follows:
Since 5.0
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddMissingTopicHandler | ( | string | topicPath, |
IMissingTopicHandler | handler | ||
) |
Registers a IMissingTopicHandler to handle requests for a branch of the topic tree.
The provided handler is called when a client subscribes or fetches using a topic selector that matches no existing topics. This allows a control client to intercede when another session requests a topic that does not exist. The control client may use any of the AddTopic(*) methods to create the topic, take some other action, or do nothing, before allowing the client operation to proceed by calling IMissingTopicNotification.Proceed(). Alternatively, the control client can call IMissingTopicNotification.Cancel() to discard the request.
A control client can register multiple handlers, but may only register a single handler for a given topic path. See ITopicTreeHandler.OnActive. A handler will only be called for topic selectors with a ITopicSelector.PathPrefix that starts with or is equal to the given topic path. If the path prefix matches multiple handlers, the one registered for the most specific (longest) topic path will be called.
topicPath | The topic path. |
handler | The handler for the specified branch (unless overridden by a handler registered against a more specific branch). |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopic | ( | string | topicPath, |
ITopicDetails | details, | ||
ITopicControlAddCallback | callback | ||
) |
Sends a request to the server to add a topic.
topicPath | The full path of the topic to be created. |
details | The details of the topic to be created. |
callback | The callback that is invoked with the result. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopic | ( | string | topicPath, |
ITopicDetails | details, | ||
IBytes | value, | ||
ITopicControlAddCallback | callback | ||
) |
Sends a request to the server to add a topic.
The topic will be initialized with the given value during creation and therefore the value must be compatible with the TopicType otherwise an TopicAddFailReason.INITIALISE_ERROR will be returned.
topicPath | The full path of the topic to be created. |
details | The details of the topic to be created. |
value | The initial value. If this is specified as null, the effect is the same as calling AddTopic{TContext}(string,ITopicDetails,TContext,ITopicControlAddContextCallback{TContext}). A value may only be supplied for a topic that is stateful. An instance of IContent may be supplied as value. |
callback | The callback that is invoked with the result. |
ITopicDetails PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopic | ( | string | topicPath, |
TopicType | topicType, | ||
ITopicControlAddCallback | callback | ||
) |
Sends a request to the server to add a topic.
This is a convenience method which is equivalent to a call to AddTopic(string,ITopicDetails,ITopicControlAddCallback) with the details generated from NewDetails(TopicType) allowing a topic to be added with default details.
The details generated are returned and may be used to pass to other calls of AddTopic(*).
topicPath | The full path of the topic to be created. |
topicType | The type of the topic to be created. |
callback | The callback that is invoked with the result. |
ITopicDetails PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopic | ( | string | topicPath, |
TopicType | topicType, | ||
IBytes | value, | ||
ITopicControlAddCallback | callback | ||
) |
Sends a request to the server to add a topic.
This is a convenience method which is equivalent to a call to AddTopic(string,ITopicDetails,IBytes,ITopicControlAddCallback) with the details generated from NewDetails(TopicType) allowing a topic to be added with default details.
If using this mechanism, it is important to understand what the default details for the topic type would be. The documentation of the relevant ITopicDetailsBuilder subtype should be consulted.
The details generated are returned and may be used to pass to other calls of AddTopic(*).
topicPath | The full path of the topic to be created. |
topicType | The type of the topic to be created. |
value | The initial value. If this is specified as null, the effect is the same as calling AddTopic(string,TopicType,ITopicControlAddCallback). A value may only be supplied for a topic that is stateful. An instance of IContent may be supplied as value. |
callback | The callback that is invoked with the result. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopic | ( | string | topicPath, |
ITopicSpecification | specification, | ||
ITopicControlAddCallback | callback | ||
) |
Sends a request to the server to add a topic.
Since 5.8
topicPath | The full path of the topic to be created. |
specification | The topic specifications of the topic to be created. A specification can be created using NewSpecification(TopicType). |
callback | The callback that is invoked with the result. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopic | ( | string | topicPath, |
ITopicSpecification | specification, | ||
IBytes | value, | ||
ITopicControlAddCallback | callback | ||
) |
Sends a request to the server to add a topic, specifying its initial value.
The topic will be initialized with the given value during creation and therefore the value must be compatible with the TopicType. Otherwise, an TopicAddFailReason.INITIALISE_ERROR will be returned.
Since 5.8
topicPath | The full path of the topic to be created. |
specification | The topic specifications of the topic to be created. A specification can be created using NewSpecification(TopicType). |
value | The initial value. If this is specified as null, the effect is the same as calling AddTopic(string,ITopicSpecification,ITopicControlAddCallback). A value may only be supplied for a topic that is stateful. An instance of IContent may be supplied as value. |
callback | The callback that is invoked with the result. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopic< TContext > | ( | string | topicPath, |
ITopicDetails | details, | ||
TContext | context, | ||
ITopicControlAddContextCallback< TContext > | callback | ||
) |
Sends a request to the server to add a topic.
TContext | The context type. |
topicPath | The full path of the topic to be created. |
details | The details of the topic to be created. |
context | The context object passed to the callback with the reply to allow requests and replies to be correlated. The caller may use any convenient object reference, including null. |
callback | The callback that is invoked with the result. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopic< TContext > | ( | string | topicPath, |
ITopicDetails | details, | ||
IBytes | value, | ||
TContext | context, | ||
ITopicControlAddContextCallback< TContext > | callback | ||
) |
Sends a request to the server to add a topic.
TContext | The context type. |
topicPath | The full path of the topic to be created. |
details | The details of the topic to be created. |
value | The initial value. If this is specified as null, the effect is the same as calling AddTopic{TContext}(string,ITopicDetails,TContext,ITopicControlAddContextCallback{TContext}). A value may only be supplied for a topic that is stateful. An instance of IContent may be supplied as value. |
context | The context object passed to the callback with the reply to allow requests and replies to be correlated. The caller may use any convenient object reference, including null. |
callback | The callback that is invoked with the result. |
ITopicDetails PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopic< TContext > | ( | string | topicPath, |
TopicType | topicType, | ||
TContext | context, | ||
ITopicControlAddContextCallback< TContext > | callback | ||
) |
Sends a request to the server to add a topic.
TContext | The context type. |
topicPath | The full path of the topic to be created. |
topicType | The type of the topic to be created. |
context | The context object passed to the callback with the reply to allow requests and replies to be correlated. The caller may use any convenient object reference, including null. |
callback | The callback that is invoked with the result. |
ITopicDetails PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopic< TContext > | ( | string | topicPath, |
TopicType | topicType, | ||
IBytes | value, | ||
TContext | context, | ||
ITopicControlAddContextCallback< TContext > | callback | ||
) |
Sends a request to the server to add a topic.
TContext | The context type. |
topicPath | The full path of the topic to be created. |
topicType | The type of the topic to be created. |
value | The initial value. If this is specified as null, the effect is the same as calling AddTopic{TContext}(string,TopicType,TContext,ITopicControlAddContextCallback{TContext}). A value may only be supplied for a topic that is stateful. An instance of IContent may be supplied as value. |
context | The context object passed to the callback with the reply to allow requests and replies to be correlated. The caller may use any convenient object reference, including null. |
callback | The callback that is invoked with the result. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopic< TContext > | ( | string | topicPath, |
ITopicSpecification | specification, | ||
TContext | context, | ||
ITopicControlAddContextCallback< TContext > | callback | ||
) |
Sends a request to the server to add a topic.
Since 5.8
TContext | The context type. |
topicPath | The full path of the topic to be created. |
specification | The topic specifications of the topic to be created. A specification can be created using NewSpecification(TopicType). |
context | The context object passed to the callback with the reply to allow requests and replies to be correlated. The caller may use any convenient object reference, including null. |
callback | The callback that is invoked with the result. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopic< TContext > | ( | string | topicPath, |
ITopicSpecification | specification, | ||
IBytes | value, | ||
TContext | context, | ||
ITopicControlAddContextCallback< TContext > | callback | ||
) |
Sends a request to the server to add a topic.
Since 5.8
TContext | The context type. |
topicPath | The full path of the topic to be created. |
specification | The topic specifications of the topic to be created. A specification can be created using NewSpecification(TopicType). |
value | The initial value. If this is specified as null, the effect is the same as calling AddTopic{TContext}(string,ITopicSpecification,TContext,ITopicControlAddContextCallback{TContext}). A value may only be supplied for a topic that is stateful. An instance of IContent may be supplied as value. |
context | The context object passed to the callback with the reply to allow requests and replies to be correlated. The caller may use any convenient object reference, including null. |
callback | The callback that is invoked with the result. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopicEventListener | ( | string | topicPath, |
ITopicControlTopicEventListener | listener | ||
) |
Register a ITopicControlTopicEventListener to receive topic events for a branch of the topic tree.
This allows a client to receive different events for topics. These events are emitted when a topic is subscribed to by one or more sessions after previously having no subscribers, or when a topic is no longer subscribed to by any session. These events are averaged over a small window of time to prevent rapid dispatch of events that ultimately return a topic to its previous state.
Each control session may register a single handler for a branch. See Callbacks.ITopicTreeHandler.OnRegistered.
topicPath | The topic path. |
listener | The listener for the specified branch (unless overriden by a listener registered against a more specific branch). |
ITopicDetails PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopicFromValue< TValue > | ( | string | topicPath, |
TValue | value, | ||
ITopicControlAddCallback | callback | ||
) |
Sends a request to the server to add a topic where the type and initial value for the topic are derived from a provided value object.
See ITopicControl documentation for full details of how this method may be used.
Since 5.3
TValue | The value type. |
topicPath | The full path of the topic to be created. |
value | The value from which the topic type, metadata and initial value are to be derived. |
callback | The callback that is invoked with the result. |
ITopicDetails PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.AddTopicFromValue< TValue, TContext > | ( | string | topicPath, |
TValue | value, | ||
TContext | context, | ||
ITopicControlAddContextCallback< TContext > | callback | ||
) |
Sends a request to the server to add a topic where the type and initial value for the topic are derived from a provided value object.
See ITopicControl documentation for full details of how this method may be used.
Since 5.3
TValue | The value type. |
TContext | The context type. |
topicPath | The full path of the topic to be created. |
value | The value from which the topic type, metadata and initial value are to be derived. |
context | The context object passed to the callback with the reply to allow requests and replies to be correlated. The caller may use any convenient object reference, including null. |
callback | The callback that is invoked with the result. |
TBuilder PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.CreateDetailsBuilder< TBuilder > | ( | ) |
Creates a new topic details builder to create ITopicDetails of a type corresponding to a given builder type.
TBuilder | The builder type. |
TBuilder | : | class | |
TBuilder | : | ITopicDetailsBuilder<ITopicDetails> |
ITopicDetails PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.NewDetails | ( | TopicType | topicType | ) |
Returns new topic details of the given type set with all default settings.
This provides a simpler mechanism than creating a builder where all of the builder's default values are suitable and there are no mandatory properties.
If using this mechanism, it is important to understand what the default details for the topic type would be. The documentation of the relevant ITopicDetailsBuilder subtype should be consulted.
topicType | The topic type. |
ITopicSpecification PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.NewSpecification | ( | TopicType | topicType | ) |
Creates a new ITopicSpecification for a given topic type.
Since 5.8
topicType | The topic type. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.Remove | ( | string | topicSelector, |
ITopicControlRemovalCallback | callback | ||
) |
Sends a request to remove one or more topics at the server.
The topics to remove will depend upon the nature of the topic selector specified. If the selector does not have descendant pattern qualifiers (i.e. / or //), only those topics that exist at paths indicated by the selector will be removed and not their descendants. If a single / qualifier is specified, all descendants of the matching topic paths will be removed. If // is specified, all branches of the topic tree that match the selector (i.e topics at the selected paths and all descendants of the selected paths) will be removed.
This method will not work over the deprecated DPT transport protocol.
Since 5.9.
topicSelector | The topic selector expression specifying the topics to remove. |
callback | The callback that is invoked with the result. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.Remove< TContext > | ( | string | topicSelector, |
TContext | context, | ||
ITopicControlRemovalContextCallback< TContext > | callback | ||
) |
Sends a request to remove one or more topics at the server.
The topics to remove will depend upon the nature of the topic selector specified. If the selector does not have descendant pattern qualifiers (i.e. / or //), only those topics that exist at paths indicated by the selector will be removed and not their descendants. If a single / qualifier is specified, all descendants of the matching topic paths will be removed. If // is specified, all branches of the topic tree that match the selector (i.e topics at the selected paths and all descendants of the selected paths) will be removed.
This method will not work over the deprecated DPT transport protocol.
Since 5.9.
TContext | The context type. |
topicSelector | The topic selector expression specifying the topics to remove. |
context | The context object passed to the callback with the reply to allow requests and replies to be correlated. The caller may use any convenient object reference, including null. |
callback | The callback that is invoked with the result. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.RemoveTopics | ( | string | topics, |
ITopicControlRemoveCallback | callback | ||
) |
Sends a request to remove one or more topics at the server.
Any descendants of the matched topics will also be removed.
topics | The topic selector expression specifying one or more topics to remove. |
callback | The callback that is invoked with the result. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.RemoveTopics< TContext > | ( | string | topics, |
TContext | context, | ||
ITopicControlRemoveContextCallback< TContext > | callback | ||
) |
Sends a request to remove one or more topics at the server.
Any descendants of the matched topics will also be removed.
TContext | The context type. |
topics | The topic selector expression specifying one or more topics to remove. |
context | The context object passed to the callback with the reply to allow requests and replies to be correlated. The caller may use any convenient object reference, including null. |
callback | The callback that is invoked with the result. |
void PushTechnology.ClientInterface.Client.Features.Control.Topics.ITopicControl.RemoveTopicsWithSession | ( | string | topicPath, |
Callbacks.ITopicTreeHandler | registrationHandler | ||
) |
Registers a deferred action to remove a branch of the topic tree.
The server will remove the topics if this session is closed. If several client sessions request removal of the same branch, the topics will not be removed until the last session is closed.
For example, suppose two client sessions both call
. When both sessions are closed, either explicitly using ISession.Close() or by the server, the topic a/b and all of its descendants will be removed. This method is typically used by a client that has added one or more topics to tidy up and remove the topics if it is ever disconnected from the server or otherwise fails.
The server can reject a RemoveTopicsWithSession call if the given topic path conflicts with existing registrations. Different sessions may call this method for the same topic path, but not for topic paths above or below existing registrations on the same branch of the topic tree.
The following callbacks will be delivered to the provided registration handler:
Since 5.1
topicPath | The topic path. |
registrationHandler |