subscribe method
Implementation
int subscribe(
String uri,
String contract,
void Function(String, int) onSuccess,
void Function(String, int) onError,
void Function(String) onNotification,
void Function(String, int) onSubscriptionError) {
_idCounter++;
_subscriptionCounter++;
_requestResultCbMap[_idCounter] = onSuccess;
_requestErrorCbMap[_idCounter] = onError;
_notifyCbMap[_subscriptionCounter] = onNotification;
_subscriptionErrorCbMap[_subscriptionCounter] = onSubscriptionError;
String mdsUri = uri;
String mdsContract = contract;
if (defaultTargetPlatform == TargetPlatform.android) {
mdsUri = "suunto://MDS/EventListener";
Map<String, dynamic> contractMap = jsonDecode(mdsContract);
contractMap["Uri"] = uri;
mdsContract = json.encode(contractMap);
}
_channel.invokeMethod('subscribe', <String, dynamic>{
"uri": mdsUri,
"contract": mdsContract,
"requestId": _idCounter,
"subscriptionId": _subscriptionCounter
});
return _subscriptionCounter;
}