Based on an Expression

AMPS provides an If module for stopping execution of the action unless a specific condition is met.

This module does not add any variables to the AMPS context.

For example, the following action publishes a message to a topic if a client with a name that matches a specific expression logs on.

<Actions>
    <Action>
        <On>
            <Module>amps-action-on-connect-client</Module>
        </On>
        <If>
            <Module>amps-action-if-condition</Module>
            <Options>
                <Condition>'{{AMPS_CLIENT_NAME}}' LIKE 'important'</Condition>
            </Options>
        </If>
        <Do>
            <Module>amps-action-do-publish-message</Module>
            <Options>
               <Topic>important-logon-notification</Topic>
               <MessageType>json</MessageType>
               <Data>{"name":"{{AMPS_CLIENT_NAME}}"}</Data>
            </Options>
        </Do>
    </Action>
</Actions>

The example above is provided to illustrate use of amps-action-if-condition.

In practice, this could also be done using an amps-action-on-publish-message action to monitor the /AMPS/ClientStatus topic with a filter.

Last updated

Copyright 2013-2024 60East Technologies, Inc.