

終止支援通知： 將於 2026 AWS 年 5 月 20 日結束對 的支援 AWS SimSpace Weaver。2026 年 5 月 20 日之後，您將無法再存取 SimSpace Weaver 主控台或 SimSpace Weaver 資源。如需詳細資訊，請參閱[AWS SimSpace Weaver 終止支援](https://docs.aws.amazon.com/simspaceweaver/latest/userguide/simspaceweaver-end-of-support.html)。

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 逐一查看已訂閱實體的事件
<a name="working-with_app-sdk_events_sub"></a>

使用 `AllSubscriptionEvents()`取得已訂閱實體 （應用程式訂閱區域中的實體） 的事件清單。函數具有下列簽章：

```
Result<SubscriptionChangeList> AllSubscriptionEvents(Transaction& txn)
```

然後，使用迴圈逐一查看實體，如下列範例所示。

**Example 範例**  

```
WEAVERRUNTIME_TRY(Api::SubscriptionChangeList subscriptionChangeList, Api::AllSubscriptionEvents(transaction));

for (const Api::SubscriptionEvent& event : subscriptionChangeList.changes)
{
    Api::Entity entity = event.entity;
    Api::ChangeListAction action = event.action;

    switch (action)
    {
    case Api::ChangeListAction::None:
        // insert code to handle the event
        break;
    case Api::ChangeListAction::Remove:
        // insert code to handle the event
        break;
    case Api::ChangeListAction::Add:
        // insert code to handle the event
        break;
    case Api::ChangeListAction::Update:
        // insert code to handle the event
        break;
    case Api::ChangeListAction::Reject:
        // insert code to handle the event
        break;
    }
}
```

**事件類型**
+ `None` – 實體位於 區域，且其位置和欄位資料未修改。
+ `Remove` – 實體已從 區域移除。
+ `Add` – 實體已新增至 區域。
+ `Update` – 實體位於 區域並已修改。
+ `Reject` – 應用程式無法從 區域移除實體。

**注意**  
如果發生`Reject`事件，應用程式將在下次刻度再次嘗試傳輸。