Skip to content

Commit 31c2fda

Browse files
committed
update algorithm
1 parent 636da25 commit 31c2fda

File tree

1 file changed

+15
-29
lines changed

1 file changed

+15
-29
lines changed

index.bs

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,15 +2054,11 @@ The [=remote end steps=] with |session| and |command parameters| are:
20542054

20552055
1. Let |new subscriptions| to be a [=/list=].
20562056

2057-
1. Let |match| be false.
2057+
1. Let |matched events| to be a [=/set=].
20582058

2059-
1. For each |subscription| of |session|'s [=subscriptions=]:
2060-
2061-
1. If |match| is true:
2062-
2063-
1. [=list/append=] |subscription| to |new subscriptions|.
2059+
1. Let |matched contexts| to be a [=/set=].
20642060

2065-
1. [=Continue=].
2061+
1. For each |subscription| of |session|'s [=subscriptions=]:
20662062

20672063
1. If [=set/intersection=] of |subscription|'s [=subscription/event names=] and |event names| is an empty [=/set=]:
20682064

@@ -2072,7 +2068,7 @@ The [=remote end steps=] with |session| and |command parameters| are:
20722068

20732069
1. If |top-level traversable context ids| is an empty [=/set=]:
20742070

2075-
1. If |subscription|'s [=subscription/top-level traversable ids=] [=set/size=] is not zero:
2071+
1. If |subscription| is not [=subscription/global=]:
20762072

20772073
1. [=list/append=] |subscription| to |new subscriptions|.
20782074

@@ -2084,17 +2080,17 @@ The [=remote end steps=] with |session| and |command parameters| are:
20842080

20852081
1. If |subscription event names| [=set/contains=] |event name|:
20862082

2087-
1. [=list/Remove=] |event name| from |event names|.
2083+
1. [=list/Append=] |event name| to |matched events|.
20882084

20892085
1. [=list/Remove=] |event name| from |subscription event names|.
20902086

2091-
1. If |event names| [=set/size=] is zero, set |match| to true.
2092-
20932087
1. If |subscription event names| is not empty:
20942088

2095-
1. Set |subscription|'s [=subscription/event names=] to |subscription event names|.
2089+
1. Let |cloned subscription| be a [=subscription=] with
2090+
[=subscription/subscription id=] set to |subscription|'s [=subscription/subscription id=],
2091+
[=subscription/event names=] set to a new [=/set=] containing |subscription event names|.
20962092

2097-
1. [=list/append=] |subscription| to |new subscriptions|.
2093+
1. [=list/append=] |cloned subscription| to |new subscriptions|.
20982094

20992095
1. Otherwise:
21002096

@@ -2106,21 +2102,12 @@ The [=remote end steps=] with |session| and |command parameters| are:
21062102

21072103
Note: unsubscribe by contexts is deprecated and will be removed in the future versions.
21082104

2109-
1. If [=set/intersection=] of |event names| and |subscription|'s [=subscription/event names=]|'s [=set/size=]
2110-
does not equal |event names|'s [=set/size=]:
2111-
2112-
1. [=list/append=] |subscription| to |new subscriptions|.
2113-
2114-
1. [=Continue=].
2115-
21162105
1. Let |event map| be an empty [=/map=].
21172106

21182107
1. For each |event name| in |subscription|'s [=subscription/event names=]:
21192108

21202109
1. Set |event map|[|event name|] to [=set/clone=] of |subscription|'s [=subscription/top-level traversable ids=].
21212110

2122-
1. Let |context ids to remove| be an empty [=/set=].
2123-
21242111
1. For each |event name| in |event names|:
21252112

21262113
1. If |event map|[|event name|] does not exist,
@@ -2130,18 +2117,16 @@ The [=remote end steps=] with |session| and |command parameters| are:
21302117

21312118
1. If |event map|[|event name|] [=set/contains=] |top-level traversable id|:
21322119

2133-
1. [=list/Append=] |top-level traversable id| to |context ids to remove|.
2120+
1. [=list/Append=] |top-level traversable id| to |matched contexts|.
2121+
2122+
1. [=list/Append=] |event name| to |matched events|.
21342123

21352124
1. [=list/Remove=] |top-level traversable id| from |event map|[|event name|].
21362125

21372126
1. If |event map|[|event name|] is an empty [=/set=],
21382127

21392128
1. [=map/Remove=] |event map|[|event name|].
21402129

2141-
1. For each |top-level traversable id| of |context ids to remove|:
2142-
2143-
1. [=list/Remove=] |top-level traversable id| from |top-level traversable context ids|.
2144-
21452130
1. For each |event name| → |remaining top-level traversable ids| in |event map|:
21462131

21472132
1. Let |partial subscription| be a [=subscription=] with
@@ -2151,9 +2136,10 @@ The [=remote end steps=] with |session| and |command parameters| are:
21512136

21522137
1. [=list/append=] |partial subscription| to |new subscriptions|.
21532138

2154-
1. If |top-level traversable context ids| is empty, set |match| to true.
2139+
1. If |matched events| does not equal |event names|, return [=error=] with [=error code=] [=invalid argument=].
21552140

2156-
1. If |match| is false, return [=error=] with [=error code=] [=invalid argument=].
2141+
1. If |top-level traversable context ids| is not empty and |matched contexts| does not equal
2142+
|top-level traversable context ids|, return [=error=] with [=error code=] [=invalid argument=].
21572143

21582144
1. Set |session|'s [=subscriptions=] to |new subscriptions|.
21592145

0 commit comments

Comments
 (0)