Utility Methods API for Dart SDK
The methods on this page are utility methods that don't fit into other categories.
Pause
Call the pause()
method to force the SDK to stop all requests to PubNub server when there are active subscribe channels.
Method(s)
To pause()
the data transmission you can use the following method(s) in Dart SDK.
pause()
This method doesn't take any arguments.
Sample code
Reference code
import 'package:pubnub/pubnub.dart';
void main() async {
// Create PubNub instance with default keyset.
var pubnub = PubNub(
defaultKeyset: Keyset(
subscribeKey: 'demo',
publishKey: 'demo',
userId: UserId('myUniqueUserId'),
),
);
// Subscribe to a channel
var channel = "getting_started";
var subscription = pubnub.subscribe(channels: {channel});
show all 24 linesResume
Call the resume()
method to force the SDK to try and reach out PubNub.
Method(s)
To resume()
the data transmission you can use the following method(s) in Dart SDK.
resume()
Sample code
subscription.resume()
This method doesn't take any arguments.
Time
This function returns the current timetoken value from the PubNub network.
Algorithm constructing the timetoken
timetoken = (Unix epoch time in seconds) * 10000000
Example of creating a timetoken for a specific time and date:
08/19/2013 @ 9:20pm in UTC = 1376961606
timetoken = 1376961606 * 10000000
timetoken = 13769616060000000
Method(s)
To fetch Time you can use the following method(s) in Dart SDK:
time()
Sample code
var response = await pubnub.time();
Returns
The time()
operation returns a Timetoken
which contains the following operations:
Method | Description |
---|---|
value Type: int | Returns an int representation of current timetoken. |