NT4Client class
Constructors
NT4Client ({required String serverBaseAddress , void onConnect ()?, void onDisconnect ()? })
Create an NT4 client. This will connect to an NT4 server running at
serverBaseAddress
. This should be either 'localhost' if running a
simulator, or 10.TE.AM.2 if running on a robot.
Example: '10.30.15.2'
Methods
addSample (NT4Topic topic , dynamic data , [int ? timestamp ])
→ void
Add a sample of data for a given topic
addSampleFromName (String topic , dynamic data , [int ? timestamp ])
→ bool
Add a sample of data for a topic with a given name, topic
If the topic with the supplied name is not published, no data will
be sent.
clearAllSubscriptions ()
→ void
Clear all subscriptions for the client. This will unsubscribe from
all previously subscribed to topics
connectionStatusStream ()
→ Stream <bool >
Create a stream that represents the status of the connection
to the NT4 server
getLastAnnouncedValueByName (String topic )
→ Object ?
Returns the last sample of data the client receieved for the given topic
.
getLastAnnouncedValueByTopic (NT4Topic topic )
→ Object ?
Returns the last sample of data the client receieved for the given topic
.
getLastTimestampByName (String topic )
→ DateTime ?
Returns the timestamp of the last sample of data the client receieved for the given topic
.
getLastTimestampByTopic (NT4Topic topic )
→ DateTime ?
Returns the timestamp of the last sample of data the client receieved for the given topic
.
getNewPubUID ()
→ int
getNewSubUID ()
→ int
getTopicFromName (String topic )
→ NT4Topic ?
Get an already announced topic with a given name, topic
latencyStream ()
→ Stream <int >
Creates a stream of the latency in milliseconds from the program to the NT4 server
noSuchMethod (Invocation invocation )
→ dynamic
Invoked when a nonexistent method or property is accessed.
inherited
publishNewTopic (String name , String type )
→ NT4Topic
Create and publish a new topic with a given name
and type
publishTopic (NT4Topic topic )
→ void
Publish a given topic
setProperties (NT4Topic topic , bool isPersistent , bool isRetained )
→ void
Set the properties of a topic
setServerBaseAddress (String serverBaseAddress )
→ void
Change the host address of the NT4 server
subscribe (String topic , NT4SubscriptionOptions options )
→ NT4Subscription
Subscribe to a topic with the name topic
and a period of period
subscribeAllSamples (String topic )
→ NT4Subscription
Subscribe to all samples for a given topic with the name topic
.
This will receive all data published to this topic instead of being
limited to a given rate.
subscribeAndRetrieveData <T > (String topic , {dynamic timeout = const Duration(seconds: 2, milliseconds: 500) })
→ Future <T? >
Temporarily creates a subscription to the topic
and returns the first value the server sends
subscribePeriodic (String topic , [double period = 0.1 ])
→ NT4Subscription
Subscribe to a topic with the name topic
and a period of period
toString ()
→ String
A string representation of this object.
inherited
unpublishTopic (NT4Topic topic )
→ void
Unpublish a given topic
unSubscribe (NT4Subscription sub )
→ void
Unsubscribe from the given subscription, sub
The client will stop receiving any data for this subscription