Skip to content

Commit

Permalink
update algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN committed Jan 9, 2025
1 parent 636da25 commit 31c2fda
Showing 1 changed file with 15 additions and 29 deletions.
44 changes: 15 additions & 29 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2054,15 +2054,11 @@ The [=remote end steps=] with |session| and |command parameters| are:

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

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

1. For each |subscription| of |session|'s [=subscriptions=]:

1. If |match| is true:

1. [=list/append=] |subscription| to |new subscriptions|.
1. Let |matched contexts| to be a [=/set=].

1. [=Continue=].
1. For each |subscription| of |session|'s [=subscriptions=]:

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

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

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

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

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

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

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

1. [=list/Remove=] |event name| from |event names|.
1. [=list/Append=] |event name| to |matched events|.

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

1. If |event names| [=set/size=] is zero, set |match| to true.

1. If |subscription event names| is not empty:

1. Set |subscription|'s [=subscription/event names=] to |subscription event names|.
1. Let |cloned subscription| be a [=subscription=] with
[=subscription/subscription id=] set to |subscription|'s [=subscription/subscription id=],
[=subscription/event names=] set to a new [=/set=] containing |subscription event names|.

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

1. Otherwise:

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

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

1. If [=set/intersection=] of |event names| and |subscription|'s [=subscription/event names=]|'s [=set/size=]
does not equal |event names|'s [=set/size=]:

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

1. [=Continue=].

1. Let |event map| be an empty [=/map=].

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

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

1. Let |context ids to remove| be an empty [=/set=].

1. For each |event name| in |event names|:

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

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

1. [=list/Append=] |top-level traversable id| to |context ids to remove|.
1. [=list/Append=] |top-level traversable id| to |matched contexts|.

1. [=list/Append=] |event name| to |matched events|.

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

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

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

1. For each |top-level traversable id| of |context ids to remove|:

1. [=list/Remove=] |top-level traversable id| from |top-level traversable context ids|.

1. For each |event name| → |remaining top-level traversable ids| in |event map|:

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

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

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

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

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

Expand Down

0 comments on commit 31c2fda

Please sign in to comment.