Skip to main content

On Subscribe or Unsubscribe

AMPS provides modules for running actions when a client subscribes or unsubscribes.

The amps-action-on-subscribe runs actions when an AMPS client enters a subscription command. The amps-action-on-unsubscribe runs actions when an AMPS client unsubscribes (either by sending an explicit unsubscribe command or by disconnecting).

These modules require the following parameters:

ParameterDescription

Topic

(required)

Specifies the topic or topic regular expression pattern to monitor for subscribe commands.

MessageType

(required)

The message type of the topic to monitor for subscribe or unsubscribe. There is no default for this parameter.

These modules add the following variables to the AMPS context:

VariableDescription
AMPS_TOPICThe name of the topic specified by the subscribe or unsubscribe command.
AMPS_CLIENT_NAMEThe name of the client submitting the command.
AMPS_OPTIONSThe options on the subscription.
AMPS_FILTERThe filter for the subscription.