LinkProvider class
Main Entry Point for dsalinks on the Dart VM
Constructors
-
LinkProvider(List<
String> args, String prefix, {bool isRequester = false, String command = 'link', bool isResponder = true, Map? defaultNodes, Map? nodes, Map<String, NodeFactory> ? profiles, NodeProvider? provider, bool enableHttp = true, bool encodePrettyJson = false, bool autoInitialize = true, bool strictOptions = false, bool exitOnFailure = true, bool loadNodesJson = true, bool strictTls = false, String defaultLogLevel = 'INFO', bool savePrivateKey = true, Requester? overrideRequester, Responder? overrideResponder, NodeProvider? nodeProvider, Map? linkData, Map<String, String> ? commandLineOptions}) -
Create a Link Provider.
argsare the command-line arguments to pass in.prefixis the link name.isRequesterspecifies if you are a requester or not.isResponderspecifies if you a responder or not.commandis the command name for this link. BothdefaultNodesandnodesspecify the default nodes to initialize if a nodes.json is not present.profilesspecify the profiles for this link.provideris a node provider. If it is not specified, one will be created for you.enableHttptoggles whether to enable HTTP fallbacks.encodePrettyJsonspecifies whether to encode pretty JSON files when writing the nodes.jsonautoInitializespecifies whether to initialize the link inside the constructor.strictOptionstoggles allowing trailing options in the argument parser.exitOnFailuretoggles exiting when the link fails.loadNodesJsonspecifies whether to load the nodes.json file or not.strictTlsspecifies if a link to a secure broker should fail, if the TLS Certificate is bad.defaultLogLevelspecifies the default log level.nodeProvideris the same asprovider. It is provided for backwards compatibility.commandLineOptionsspecifies a map of an option name to a default value, for use in expanding the command parameters.
Properties
-
args
↔ List<
String> -
The Command-line Arguments
getter/setter pair
- basePath → String
-
no setter
- brokerUrl ↔ String?
-
The Broker URL
getter/setter pair
- command ↔ String
-
The Command Name
getter/setter pair
- defaultLogLevel ↔ String
-
Default Log Level.
getter/setter pair
- defaultNodes ↔ Map?
-
Default Nodes
getter/setter pair
- didInitializationFail → bool
-
Checks if the link object is null.
no setter
- dsalinkJson ↔ Map?
-
The dsalink.json contents. This is only available after configure is called.
getter/setter pair
- enableHttp ↔ bool
-
Enable HTTP Fallback?
getter/setter pair
- encodePrettyJson ↔ bool
-
Encode Pretty JSON?
getter/setter pair
- exitOnFailure ↔ bool
-
Exit on Failure?
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- home ↔ String?
-
connect to user home space
getter/setter pair
- isInitialized → bool
-
Checks if the link object is not null.
no setter
- isRequester ↔ bool
-
Are we a requester?
getter/setter pair
- isResponder ↔ bool
-
Are we a responder?
getter/setter pair
- link ↔ HttpClientLink?
-
The Link Object
getter/setter pair
- linkData ↔ Map?
-
getter/setter pair
- loadNodesJson ↔ bool
-
Load the nodes.json?
getter/setter pair
- logTag ↔ String?
-
Log Tag
getter/setter pair
-
onRequesterReady
→ Future<
Requester> -
Completes when the requester is ready for use.
no setter
- overrideRequester ↔ Requester?
-
getter/setter pair
- overrideResponder ↔ Responder?
-
getter/setter pair
- parsedArguments → ArgResults?
-
no setter
- prefix ↔ String
-
The Link Name
getter/setter pair
- privateKey ↔ PrivateKey
-
The Private Key
getter/setter pair
-
profiles
↔ Map<
String, NodeFactory> ? -
Profiles
getter/setter pair
- provider ↔ NodeProvider?
-
The Node Provider
getter/setter pair
- qosPersistenceEnabled → bool
-
persist qos2 and qos3 subscription to disk, default to false;
no setter
- remotePath → String?
-
Remote Path of Responder
no setter
- requester → Requester?
-
The requester object.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- savePrivateKey ↔ bool
-
Save Private Key?
getter/setter pair
- strictOptions ↔ bool
-
Strict Options?
getter/setter pair
- strictTls ↔ bool
-
Strict TLS connections?
getter/setter pair
- token ↔ String?
-
connection token
getter/setter pair
- valuePersistenceEnabled → bool
-
persist value setting to disk, default to true;
no setter
Methods
-
addCommandLineOption(
String name, [String defaultValue = '']) → void -
addNode(
String path, Map m) → LocalNode? -
Adds a node with the given configuration in
mat the givenpath. In order for this method to work, the node provider must be mutable. If you did not specify a custom node provider, the created provider is mutable. -
chooseBroker(
Stream< String> brokers) → Future<String> - A Method that a Custom Link Provider can override for changing how to choose a broker. By default this selects the first broker available.
-
close(
) → void - Closes the link by disconnecting from the broker. You can call connect again once you have closed a link.
-
configure(
{ArgParser? argp, OptionResultsHandler? optionsHandler}) → bool -
Configure the link.
If
argpis provided for argument parsing, it is used. This includes: -
connect(
) → Future - Connects the link to the broker.
-
createHttpLink(
) → HttpClientLink -
getCommandLineValue(
String name) → String -
getConfig(
String key) → Object? - Gets a configuration value from the dsalink.json
-
getNode(
String path) → LocalNode? - Gets the node at the specified path.
-
init(
) → void - Initializes the Link. There is no guarantee that the link will be ready when this method returns. If the configure method is not called prior to calling this method, it is called.
-
loadNodesFile(
) → void -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onNodesDeserialized(
Map json) → void - Handles deserialization of node data.
-
onValueChange(
String path, {int cacheLevel = 1}) → Stream< ValueUpdate> -
Retrieves a Broadcast Stream which subscribes to
pathwith the specifiedcacheLevel. The node is only subscribed if there is at least one stream subscription. When the stream subscription count goes to 0, the node is unsubscribed from. -
removeNode(
String path) → void -
Removes the method at the specified
path. In order for this method to work, the node provider must be mutable. If you did not specify a custom node provider, the created provider is mutable. -
save(
) → void - Synchronously saves the nodes.json file.
-
saveAsync(
) → Future - Asynchronously saves the nodes.json file.
-
stop(
) → void - An alias to close.
-
syncValue(
String path) → void -
Gets the value for
pathand forcibly updates the value to the same exact value. -
toString(
) → String -
A string representation of this object.
inherited
-
updateValue(
String path, dynamic value) → void -
Updates the value of the node at the given
pathtovalue. In order for this method to work, the node provider must be mutable. If you did not specify a custom node provider, the created provider is mutable. -
val(
String path, [dynamic value = unspecified]) → dynamic -
If only
pathis specified, this method fetches the value of the node at the given path. Ifvalueis also specified, it will set the value of the node at the given path to the specified value, and return that value.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
-
operator [](
String path) → LocalNode? -
Gets the node specified at
path. -
operator ~(
) → LocalNode? - Gets the root node.