コード例 #1
0
        for message in messageList:

            # Do work with message here!

            # Make sure to acknowledge messages with priority >= 2
            if (message.priority >= 2):
                if (message.acked != 1):
                    client.acknowledgeEmergency(message.receipt)

        # Make sure you delete messages that you recieve!
        client.deleteMessages(messageList[-1].id)


# Setups with a device configuration
client = Client("example_device.cfg")

# Get any messages sent before the client has started
messageList = client.getOutstandingMessages()

# Do work with outstanding messages

# Make sure you delete messages that you recieve!
if (messageList):
    client.deleteMessages(messageList[-1].id)

# Pass our function as a parameter, this will run 'forever'
client.getWebSocketMessages(messageCallback)

# Can optionally continue doing other work here without the need
# to poll the websocket
コード例 #2
0
# Setups with a device configuration
client = Client("example_device.cfg")

# Get any messages sent before the client has started
messageList = client.getOutstandingMessages()

# Do work with outstanding messages

# Make sure you delete messages that you recieve!
if(messageList):
    client.deleteMessages(messageList[-1].id)

# Our polling loop
while(True):
    messageList = client.getWebSocketMessages()

    # Prcoess/do work with messageList!
    if(messageList):
        for message in messageList:

            # Do work with message here!

            # Make sure to acknowledge messages with priority >= 2
            if(message.priority >= 2):
                if(message.acked != 1):
                    client.acknowledgeEmergency(message.receipt)

        # Make sure you delete messages that you recieve!
        # Input is the message id of the latest you wish to delete
        client.deleteMessages(messageList[-1].id)