Client class
Client sends and receives data between any NKN clients regardless their network condition without setting up a server or relying on any third party services. Data are end to end encrypted by default.
Constructors
- Client({ClientConfig? clientConfig})
Properties
- address ↔ String
-
NKN client address
getter/setter pair
- clientConfig ↔ ClientConfig?
-
getter/setter pair
- eventChannelStreamSubscription ↔ StreamSubscription
-
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
-
onConnect
→ Stream<
OnConnect> -
no setter
- onError → Stream
-
no setter
-
onMessage
→ Stream<
OnMessage> -
no setter
- publicKey ↔ Uint8List
-
NKN wallet public key
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- seed ↔ Uint8List
-
NKN wallet seed
getter/setter pair
Methods
-
close(
) → Future< void> - close closes the multiclient, including all clients it created and all sessions dialed and accepted. Calling close multiple times is allowed and will not have any effect.
-
getHeight(
) → Future< int?> - getHeight RPC returns the latest block height.
-
getNonce(
{bool txPool = true}) → Future< int?> - getNonce RPC gets the next nonce to use of an address. If txPool is false, result only counts transactions in ledger; if txPool is true, transactions in txPool are also counted.
-
getNonceByAddress(
String address, {bool txPool = true}) → Future< int?> - getNonceByAddress is the same as getNonce
-
getSubscribers(
{required String topic, int offset = 0, int limit = 10000, bool meta = true, bool txPool = true, Uint8List? subscriberHashPrefix}) → Future< Map< String, dynamic> ?> -
getSubscribers RPC returns the number of subscribers of a topic
(not including txPool). If
subscriberHashPrefix
is not empty, only subscriber whose sha256(pubkey+identifier) contains this prefix will be counted. Each prefix byte will reduce result count to about 1/256, and also reduce response time to about 1/256 if there are a lot of subscribers. This is a good way to sample subscribers randomly with low cost. -
getSubscribersCount(
{required String topic, Uint8List? subscriberHashPrefix}) → Future< int> -
getSubscribersCount RPC returns the number of subscribers of a topic
(not including txPool). If
subscriberHashPrefix
is not empty, only subscriber whose sha256(pubkey+identifier) contains this prefix will be counted. Each prefix byte will reduce result count to about 1/256, and also reduce response time to about 1/256 if there are a lot of subscribers. This is a good way to sample subscribers randomly with low cost. -
getSubscription(
{required String topic, required String subscriber}) → Future< Map< String, dynamic> ?> - getSubscription RPC gets the subscription details of a subscriber in a topic.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
publishText(
String topic, String data, {int maxHoldingSeconds = 8640000, bool txPool = false, int offset = 0, int limit = 1000}) → Future< OnMessage> - publishText sends bytes or string data to all subscribers of a topic with an optional config.
-
reconnect(
) → Future< void> - reconnect reconnect the multiclient
-
sendText(
List< String> dests, String data, {int maxHoldingSeconds = 8640000, dynamic noReply = true}) → Future<OnMessage> -
sendText sends bytes or string data to one or multiple destinations with an
optional config. Returned
OnMessage
will emit if a reply or ACK for this message is received. -
subscribe(
{String identifier = '', required String topic, int duration = 400000, String fee = '0', String meta = '', int? nonce}) → Future< String> - subscribe to a topic with an identifier for a number of blocks. Client using the same key pair and identifier will be able to receive messages from this topic. If this (identifier, public key) pair is already subscribed to this topic, the subscription expiration will be extended to current block height + duration. The signerRPCClient can be a client, multiclient or wallet.
-
toString(
) → String -
A string representation of this object.
inherited
-
unsubscribe(
{String identifier = '', required String topic, String fee = '0', int? nonce}) → Future< String> - unsubscribe from a topic for an identifier. Client using the same key pair and identifier will no longer receive messages from this topic. The signerRPCClient can be a client, multiclient or wallet.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
create(
Uint8List seed, {String identifier = '', int? numSubClients, ClientConfig? config}) → Future< Client> - create creates a multiclient with an account, an optional identifier, number of sub clients to create, whether to create original client without identifier prefix, and a optional client config that will be applied to all clients created. For any zero value field in config, the default client config value will be used. If config is nil, the default client config will be used.
-
install(
) → dynamic - Need to install before use.