Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DefaultSubscriptionManager

DefaultSubscriptionManager is used to resubscribe and manage client subscriptions in case of a unintended disconnection.

// create a client
let client = new amps.Client('my-client');

// Create and assign the subscription manager
client.subscriptionManager(new amps.DefaultSubscriptionManager());

// ... access the subscription manager later
client.subscriptionManager().clear();

Hierarchy

  • DefaultSubscriptionManager

Implements

Index

Constructors

constructor

  • This is the constructor for the DefaultSubscriptionManager class.

    Parameters

    • Default value _resubscriptionTimeout: number = 0

    Returns DefaultSubscriptionManager

Methods

clear

  • clear(): void
  • This method clears all the managed subscriptions so that in case of the disconnection there will be no subscriptions to restore.

    Returns void

resubscribe

  • resubscribe(client: Client): void
  • This method resubscribes to all the stored subscriptions using the Client object provided.

    Parameters

    • client: Client

      The AMPS client object. It must be connected.

    Returns void

resubscriptionTimeout

  • resubscriptionTimeout(timeout?: number): number
  • This method sets/gets the resubscription timeout value. It should be bigger or equal to zero. If it is equal to zero, it never times out.

    Parameters

    • Default value timeout: number = 0

      The timeout value (in milliseconds).

    Returns number

    The subscription timeout.

subscribe

  • subscribe(header: Header, messageHandler?: function): void
  • This method performs the subscription to a topic.

    Parameters

    • header: Header

      The subscription command header with all command data.

    • Optional messageHandler: function

      The message handler callback function. Not required in case of 'replace' or 'pause' subscriptions.

    Returns void

unsubscribe

  • unsubscribe(subId: string): void
  • This method unsubcribes from a topic using the subscription id.

    Parameters

    • subId: string

      The subscription id.

    Returns void