示例#1
0
    async def on_broker_client_disconnected(self, client_id):

        didsplit = str(client_id).split("@")

        bot = bumper.bot_get(didsplit[0])
        if bot:
            bumper.bot_set_mqtt(bot["did"], False)
            return

        clientresource = didsplit[1].split("/")[1]
        client = bumper.client_get(clientresource)
        if client:
            bumper.client_set_mqtt(client["resource"], False)
            return
示例#2
0
def test_client_db():
    bumper.db = "tests/tmp.db"  # Set db location for testing
    bumper.client_add("user_123", "realm_123", "resource_123")
    assert bumper.client_get("resource_123")  # Test client was added

    bumper.client_set_mqtt("resource_123", True)
    assert bumper.client_get("resource_123")[
        "mqtt_connection"]  # Test that mqtt was set True for client

    bumper.client_set_xmpp("resource_123", False)
    assert (bumper.client_get("resource_123")["xmpp_connection"] == False
            )  # Test that xmpp was set False for client
    assert (len(bumper.get_disconnected_xmpp_clients()) == 1
            )  # Test len of connected xmpp clients is 1
示例#3
0
    async def on_broker_client_disconnected(self, client_id):
        try:
            didsplit = str(client_id).split("@")

            bot = bumper.bot_get(didsplit[0])
            if bot:
                bumper.bot_set_mqtt(bot["did"], False)

            #clientuserid = didsplit[0]
            clientresource = didsplit[1].split("/")[1]
            client = bumper.client_get(clientresource)
            if client:
                bumper.client_set_mqtt(client["resource"], False)

        except Exception as e:
            mqttserverlog.exception("{}".format(e))