1916
1917
addSubscriber(resource: URI, clientId: string): void {
1919
>
const wasUnsubscribed = !set || set.size === 0;
1920
>
if (!set) {
1921
>
set = new Set();
1922
>
this._resourceSubscribers.set(resource, set);
1923
>
}
1924
>
set.add(clientId);
1925
>
// A new subscriber means the session is being observed again; cancel
1926
>
// any pending GC or idle-release armed while it had no subscribers.
1927
>
this._cancelPendingSessionGc(resource);
1928
>
this._cancelPendingSessionRelease(resource);
1929
>
// 0→1 transition — covers both the full subscribe path AND the
1930
>
// handshake fast-path used by `ProtocolServerHandler` when state is
1931
>
// already cached. The coordinator decides whether the URI is one
1932
>
// it cares about (e.g. uncommitted changeset → trigger refresh).
1933
>
if (wasUnsubscribed) {
1934
>
this._changesetCoordinator.onFirstSubscriber(resource);
1935
>
}
1936
>
}
1937
1938
unsubscribe(resource: URI, clientId: string): void {