migratorydata_client_dart_v6 1.0.6 migratorydata_client_dart_v6: ^1.0.6 copied to clipboard
This MigratoryData client library is written in Dart. One important use of this library is that it allows you to use the Flutter framework for building realtime applications natively compiled for mobi [...]
import 'dart:async';
import 'dart:convert';
import 'dart:typed_data';
import 'dart:math';
import 'package:migratorydata_client_dart_v6/client.dart';
void main() {
var client = MigratoryDataClient();
client.setEntitlementToken("some-token");
client.setListener(ListenerImpl());
// client.setEncryption(true);
client.setServers(["localhost:8800"]);
client.subscribe(["/vehicles/1/speed"]);
client.connect();
Timer.periodic(Duration(seconds: 5), (Timer t) {
client.publish(MigratoryDataMessage(
"/vehicles/1/speed",
Uint8List.fromList(utf8.encode(Random().nextInt(200).toString()))));
});
}
class ListenerImpl implements MigratoryDataListener {
@override
onMessage(MigratoryDataMessage message) {
print(message);
}
@override
onStatus(String type, String info) {
print("$type - $info");
}
}