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. args are the command-line arguments to pass in. prefix is the link name. isRequester specifies if you are a requester or not. isResponder specifies if you a responder or not. command is the command name for this link. Both defaultNodes and nodes specify the default nodes to initialize if a nodes.json is not present. profiles specify the profiles for this link. provider is a node provider. If it is not specified, one will be created for you. enableHttp toggles whether to enable HTTP fallbacks. encodePrettyJson specifies whether to encode pretty JSON files when writing the nodes.json autoInitialize specifies whether to initialize the link inside the constructor. strictOptions toggles allowing trailing options in the argument parser. exitOnFailure toggles exiting when the link fails. loadNodesJson specifies whether to load the nodes.json file or not. strictTls specifies if a link to a secure broker should fail, if the TLS Certificate is bad. defaultLogLevel specifies the default log level. nodeProvider is the same as provider. It is provided for backwards compatibility. commandLineOptions specifies 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
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 m at the given 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.
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 argp is provided for argument parsing, it is used. This includes:
connect() Future
Connects the link to the broker.
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 path with the specified cacheLevel. 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 path and 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 path to value. 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 path is specified, this method fetches the value of the node at the given path. If value is 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.