2

いくつかの属性を持つエンティティがあります。それぞれにサブスクリプションがあります。サブスクリプションの例を次に示します。

{ "entities": [ { "type": "Room", "isPattern": "false", "id": "Room5" } ], "attributes": [ ], "reference": "http://localhost:5050/notify", "duration": "P1M", "notifyConditions": [ { "type": "ONCHANGE", "condValues": [ "pressure" ] } ] }

問題は、属性に何らかの変更がある場合、変更されていない属性を含む完全なエンティティを通知がサブスクライブすることです。

この問題を解決するための回避策はありますか?

4

1 に答える 1

1

このattributesフィールドは、通知される属性を指定するため、condValues(「すべての属性」を意味する空のリストの代わりに) で使用されているものと同じ属性名を使用すると、通知には変更された属性のみが含まれます。あれは:

{
    "entities": [
        {
            "type": "Room",
            "isPattern": "false",
            "id": "Room5"
        }
    ],
    "attributes": [ "pressure" ],
    "reference": "http://localhost:5050/notify",
    "duration": "P1M",
    "notifyConditions": [
        {
            "type": "ONCHANGE",
            "condValues": [
                "pressure"
            ]
        }
    ]
}

この場合、エンティティをタイプで分類でき、パターンでサブスクリプションを使用する場合、エンティティごとに N サブスクリプション (値の変更を監視するエンティティに属する属性の数 N) またはエンティティ タイプごとに N サブスクリプションが必要であることに注意してください。 . 後者のオプションの例を以下に示します。

{
    "entities": [
        {
            "type": "Room",
            "isPattern": "true",
            "id": ".*"
        }
    ],
    "attributes": [ "pressure" ],
    "reference": "http://localhost:5050/notify",
    "duration": "P1M",
    "notifyConditions": [
        {
            "type": "ONCHANGE",
            "condValues": [
                "pressure"
            ]
        }
    ]
}

これによりpressure、タイプのエンティティがRoom変更されるたびに (エンティティ ID に関係なく)、そのエンティティに対するプレッシャーの通知が表示されます。

于 2015-01-19T17:24:57.267 に答える