subscribe static method

int subscribe(
  1. String uri,
  2. String contract,
  3. void onSuccess(
    1. String,
    2. int
    ),
  4. void onError(
    1. String,
    2. int
    ),
  5. void onNotification(
    1. String
    ),
  6. void onSubscriptionError(
    1. String,
    2. int
    ),
)

Make a SUBSCRIPTION request for a resource. uri must include "suunto://" prefix and device serial if needed. contract must be a json string. If the request is successful, onSuccess is called with response data in json string format, and status code. Upon error, onError is called with reason and status code. When there is a notification, onNotification is called with notification data, which is in json string format. onSubscriptionError is called when an error occurs with subscription, with reason and error status code.

This call returns a subscription id. It must be held and used when unsubscribing.

Implementation

static 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) {
  return MdsImpl().subscribe(
      uri, contract, onSuccess, onError, onNotification, onSubscriptionError);
}